Activate on satisfying a condition question

Activate on satisfying a condition question

Hi, 

I'd like to use the "Activate on satisfying a condition" option of the "Experiment Activation Mode"..

I created this condition: 

document.querySelector("div.location-top-data a.btn.blue.radius.xsmall").innerHTML == "Contact Us";

The idea is that the experiment only runs when this condition is satisfied. 

Question: the website contains pages where this same element div.location-top-data a.btn.blue.radius.xsmall is not there. Testing the script on these pages, at Chrome console, I receive this message: 

Uncaught TypeError: Cannot read property 'innerHTML' of null at <anonymous>:1:73

Is it OK that this script return this or must return "false"? Wondering if that could potentially cause any issues at pages where the element is not there. 

Thanks! 


      • Sticky Posts

      • CSS not loading in heat map view

        I ran into a problem with two different websites where when I view the heat map experiment, the CSS for the page is not loaded under the heat map overlay. When going to the page directly, everything looks fine. The page also looks right on the Experiments page where a screenshot is used as the thumbnail... The sites are both WordPress websites. I've tried both the regular snippet and async. I'm hoping this has been seen before and there's a solution. Thanks!