Targeting Experiments and Firing Goals Based on a JavaScript Condition

THIS ARTICLE WILL HELP YOU:

Target Based on JavaScript Condition

You might want to fire a conversion or run an experiment when some sort of JavaScript expression evaluates to "true". 

This DMP (Data Management Platform) feature allows it to target for example lead score/stage from your Marketing Automation tool (like Marketo, Pardot, Elequou, Hubspot or Salesforce) without too much effort.

Important Note: Any JavaScript used inside the expression has to be defined before the main Convert Experiments tracking code. If they are defined later on the page, their values cannot be used at the time of evaluation and the condition might not be matched. Convert also provides a convert.recheck() function to evaluate the condition every 50ms for 2 minutes, as the variable might not be declared when the convert script executes. You can find more information about it in this article.

Note: The javascript expression will be evaluated into the global "window" context.

Currently, it is possible to use the JavaScript expression targeting in three locations:

  1. Advanced Goal Setup - a goal can be fired if the JavaScript condition used evaluates to true:


  2. Experiment Locations - you can run an experiment on pages where a certain Javascript
    condition evaluates true:


  3. Experiment Audience - You can run an experiment for a certain group of visitors. For example, if one has a certain JavaScript variable holding the visitor status (client or anonymous), then it would be possible to run an experiment only for clients:

Keywords: trigger goal, trigger conversion