Creating a click conversion using the Advanced Editor

A click conversion counts the number of times a specific html element is clicked E.g. text link, button.

Adding a Click conversion using custom code

Click on the “JS” icon 

On the following screen add your code within the second

 

In order to track using JavaScript the platform has the function WT.click. Note syntax, case and that a colon is required after each.

// Format
WT.click({
   testAlias: value1,
   conversionPoint: value2,
   data: value5
});

// example
WT.click({
   testAlias: "ta_123",
   conversionPoint: "Click_CTA",
   data: {
       moduleType: "plp_hero"
   }
});

// example 2
WT.click({
   testAlias: "ta_123",
   conversionPoint: "Purchase",
   data: {
       revenue: 123.45,
       units: 3
   }
});

Parameters

  • testAlias: The Test Alias is automatically generated when you create a new test and can be found in the ‘Project Details’ section.
    • Replace value1 with your Test Alias name.
  • conversionPoint:
    • This defines the label that will be given to the specific conversion point. Avoid using spaces, apostrophes or special characters where possible.
    • Replace value2 with a meaningful conversion name (E.g. Click_Button)
  • Data: This function defines if custom data is required to be collected as the event is fired.
    • Replace value5 with data if no additional data collection is required.

Example in JS

document.getElementById("YOUR_ID").addEventListener("click", function(){
   WT.click({testAlias: “TA_Mytest”,conversionPoint: “Click_BuyNow”,cookieInspection: false,beacon: false
});

Example using Jquery.

$("body").on("click", ".YOUR_CLASS", function(){
   WT.click({testAlias: “TA_Mytest”,conversionPoint: “Click_BuyNow”,cookieInspection: false, beacon: false});
});

Tips and troubleshooting

 

You may need to check that your element has loaded before hooking events onto it.

On click conversions that take the visitor to new page in the same window, the event may be fired as the visitor is being redirected to another page. This can result in an event not being passed. Adding a small delay to the click event will avoid this being a possibility.

For mobile and touch devices, on.touch rather than on.click for the event trigger will in many cases be more robust.

 

Adding a Click Conversion using custom code in the post-rendering script:

 

During the test set up process, you can add Click conversion goals at step 5 “Test Details by adding custom code to the post-rendering script.

Enter your code within the ‘Post-Rendering Script’ section.