google-tag-managercontent-experiments

Google Tag Manager: GA Content Experiment code not firing on home page


I've created a Google Analytics Content Experiment in GA, copied the code, added it to my site's Google Tag Manager container, set it to trigger @

https://www.example.com
https://www.example.com/
https://www.example.com/h2/
https://www.example.com/h3/

However, every time I load https://www.example.com in any browser, I stay there and am not redirected to a variant.

GA says the experiment code is detected at /h2/ & /h3/ but not /.

The Tag Manager code is installed in the same Wordpress theme that all of the above pages use.

Help appreciated.


Solution

  • Not sure if you know but Content Experiment is now Google Optimize.

    To debug this here is what I would do:

    .async-hide { opacity: 0 !important} (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date; h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c; })(window,document.documentElement,'async-hide','dataLayer',4000, {'GTM-XXXXXX':true});