Google Tag Manager and Google Experiments / Google Optimize
-
Hi Thomas,
First of all, thank you again for this amazing plugin!
I have GTM installed for a long time now. I was invite to Google Optimize / Experiments. So I followed all the steps: I created an accound and linked it to my GA, to the appropriate view. Then I added the Optimize snippet as provided in Google Optimize.
First of all, I did not change the code I had in my template file, because I have the ‘Custom’ option set in GTM plugin. I have this code just after the opening <body> tag:
<?php if ( function_exists( ‘gtm4wp_the_gtm_tag’ ) ) { gtm4wp_the_gtm_tag(); } ?>In that same file, I added this provided code by Google Optimize just below the closing HEAD tag:
<script>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);
ga(‘create’, ‘UA-XXXXXXetc.’, ‘auto’);
ga(‘require’, ‘GTM-XXXXXetc.’);
ga(‘send’, ‘pageview’);
</script><style>.async-hide { opacity: 0 !important} </style>
<script>(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-XXXXXXetc’:true});</script>Of course, with the right GTM and UA codes.
However, If you check my site with Tag Assistant plugin, you will notice that there is an error: ‘Same web property ID is tracked twice.’
I have tried to first load the async code first. I have also tried to place both snippets of code to the top of the head section. Same results.
I have also tried deleting the ‘ga(‘create’, ‘UA-XXXXXXetc.’, ‘auto’);’ part of the snippet, but got an error in the experiment preview, that the required code was not installed correctly.
Furthermore, on some other pages than my home page, I am also getting this error in Tag Assistant: ‘Multiple installations of Google Tag Manager detected’. It is referring to the GTM code for google optimize.
Do you have any idea how I could resolve this? I hope you can help.
This is my website: https://www.vgpjewelry.nl
- The topic ‘Google Tag Manager and Google Experiments / Google Optimize’ is closed to new replies.