Experiment based on page content

Sometimes, we would like to implement an experiment based on the page content, instead of URL or Page Tag conditions.

For this we will implement a JS Condition to look for the content on the page using JQuery and if found it will bucket the visitor on the experiment if he/she visits any page with such content.

For this solution to work, you will need to create the CSS selector for the element that needs to be present on the page, to enable the experiment.

Here is the code:

(function() {
if(document.readyState === 'complete'){
return(false)}
else if(convert.$('.selector').length == 0) {
convert_recheck_experiment();
}
else return (true);
})()

This code is based in this article. And to learn how to create CSS selectors, you can see the video in this article.