You can customize your VWO SmartCode in the following ways:
Modifying the Cookie Duration
In this example, the cookie will last for a day only. Change the value from 1 to the number of days you want the cookie to be stored. Once the cookies are created, the duration cannot be altered.
When you change the cookie duration, there is a possibility of a data discrepancy.
Configuring the Timeout Interval
By default, the time-out values for the two parameters are 2000 and 2500 milliseconds, respectively. Using the following two parameters of the SmartCode, you can change the time-out interval to counter issues like slow Internet connections or incompatible IE browsers. You can set the time for which the asynchronous script will wait for the page settings to load, using the variable settings_tolerance. If the page settings load within this time interval, the code requests the VWO library (va.js or vanj.js) from our CDN and waits for the file to load at the interval indicated by the variable library_tolerance.
Hiding an Element
You can customize the SmartCode to hide an element on your webpage. This can be done using the “hide_element” field of the SmartCode. The default functionality of the asynchronous SmartCode is to hide the body of the web page initially. This is to avoid any flash of the original content on the web page while VWO applies any change.
If you wish to override the default functionality of the asynchronous SmartCode, you can replace the “body” with an empty string. The example code:
If you make this change, you might encounter issues like a flash of original content on the web page.
Setting Domain for VWO Cookies
In case, VWO cookies are not stored on your domain by default, use the following code to set the domain on which the cookies should be stored. This code snippet must be added before the VWO tracking code on your webpage.
Using jQuery of Your Webpage Instead of VWO’s jQuery
You have the option to use the jQuery of your webpage instead of the VWO’s jQuery. This typically depends on the jQuery version of your webpage. If the jQuery version of your webpage is similar or higher than the one used by VWO, your page can use its own jQuery. Currently, the jQuery version used by VWO is 1.4.2. As of now, the supported jQuery versions range from 1.4.2 to 2.x.x.
Accounts with IDs lower than the one specified above are unaffected and will continue to function normally.
If you are already using jQuery on your webpage, and the version is in the specified range, we recommend you to use the no Jquery version as it would reduce the required bandwidth and would work faster. The example code:
For Synchronous SmartCode:
For Asynchronous SmartCode:
Custom URL Setup
When a campaign has to run on multiple pages with no common pattern in the URL’s or when a campaign needs to run on specific pages and the URL pattern matches with a lot of pages that do not have to be included, then a Custom URL can be used to create a pattern that matches your requirements. Using custom URLs, you can assign virtual URLs to the pages so that a specific pattern can be generated. The example code:
Configuring Heatmap Clicks
VWO records only the first three clicks from a user in a particular session per page for generating a heatmap or clickmap report. For example, when a user lands on a test page, the first three taps or clicks by the user on the page are captured in a heatmap or clickmap report.
However, there are scenarios in which you implement multiple changes across different elements in a variation. These changes can even involve scrolling the page. In such scenarios, it is likely that capturing just three clicks might lead to missing important click data on elements you want to track. Using VWO, you can now increase the number of clicks to be tracked for each session. To know more, refer to Increasing Heatmap Clicks.
To modify the number of clicks to be tracked for each session, you need to specify the value for the “_vwo_click” field. This code snippet must be added before the VWO tracking code on your webpage. The example code: