This Article Will Help You:
- Overview
- Global Project JavaScript
- Global Experience JavaScript
- Variation JavaScript
- Calling Functions Declared There
Overview
Convert enables you to include JavaScript snippets as part of your Project, Experiment or even Variation.
Global Project JavaScript
Convert allows you to include a JS snippet in your Project. This means that all the pages that have the Convert tracking code installed will have the snippet included.
The snippet would be included just like any other library that you include in your web page.
You can edit the snippet by going to your Project Configuration.
Global Experience JavaScript
Convert Experiences allows you to insert a JavaScript snippet into a page when an experience is triggered. The snippet would be included just like any other library that you include in your web page. This only applies to experience types that include the Visual Editor (ie, you cannot do this with a Split URL Experiment).
To add JavaScript to your experience.
- Open the Visual Editor from the Experience Summary
- Click on the Snippet Editor icon.
- Select Global Experience JavaScript.
- Add the JavaScript snippet.
- Save your Experience.
The way the code is added to the page you are testing or personalizing would be equivalent to adding it to the head section inside a script tag.
Additionally, you could add JS events such as click or hover events for your code to trigger.
Variation JavaScript
Convert Experiences enables you to add a JavaScript snippet in the variation of your choice. This can only be done in experience types where the Visual Editor is available (ie, this is not possible in Split URL Experiences).
With this feature, you can test if certain functionality added by the snippet improves your conversion.
For example, you could A/B test customer support chat by adding the chat code to the Variation.
To add it:
- Open the Visual Editor from the Experience Summary
- Click on the Snippet Editor icon.
- Select Variation JavaScript
- Add your code in the editor.
The code added here will not run automatically. You would need an event to run it just as you would with any included JS library.
Calling Functions Declared There
To call a function declared in the Global Project JavaScript or the Global Experience JavaScript sections, just declare it in the following way:
// You can define the function as
window.functionName = function() {
//code here
}
// and than call it like
window.functionName()
// or
functionName();