1. Help Center
  2. Target Visitors

Manually activate experiment

Sometimes you may need to manually fire an experiment using JavaScript in order to make sure it runs just after certain flows are followed on the page. 

In order to do that, please follow the steps below:

  1. Create the experiment, as usual, except in the Experiment Locations, instead of doing a match based on the URL, you would do a match based on a JS condition.

    Inside the JS condition, the simplest condition you could use would be like this:

    (window.runExperiment ==1) 

    If you were to add this initially to a Location, the experiment will not automatically fire because the condition would be false by default; you would make it true in step 2.

  2. Whenever needed to run the experiment on the page, you need to make sure that:

    • the experiment condition becomes true; for the above condition you could just add code like the following on your source page: 

      window.runExperiment = 1;

    • trigger the experiment by adding the following code (this should be placed after the code setting window.runExperiment = 1): 

      window._conv_q = window._conv_q || [];
      window._conv_q.push(["executeExperiment",""]) 

      *in the bold area you'd have to place the experiment ID found inside the application as explained here: http://support.convert.com/hc/en-us/articles/204506639