This website works best with JavaScript enabled. Learn how to enable JavaScript.

Can I Create Campaigns On Pages Created Using AJAX?

Last updated

Yes, you can use VWO to set up changes in the AJAX elements on a webpage.

VWO applies changes to an element as soon as tracking code is loaded and doesn’t wait for the full page to be ready. In case you add an element later on the page through AJAX, use the following JS code snippet in VWO Code Editor:


_vis_opt_element_loaded(campaign_id); //change campaign_id as per the experiment ID


This is useful when changes are applied using editor operations.

If this does not work, you need to apply the changes through JavaScript code, using VWO Code Editor. While writing custom JS code, you should use vwo_$ (VWO’s inline jQuery handle) instead of $. This would ensure that JS code is executed when VWO code is triggered and is not dependent on the jQuery of the page.

You can also use the setInterval() function to check the target element; and when it’s available, apply the change, as shown in the following code:

if (window.timerX) clearInterval(window.timerX);

window.timerX = setInterval(function() {

if (vwo_$('E1').length) {

// script S1 here.


}, 100);

If your website is a single-page application, you need to execute the VWO tracking code, as explained in this article.

Was this article helpful?

Thanks for your feedback!
Please email us at to tell us what you were looking for. We'll send the answer to your inbox.

Contact Us / Login