Running Google Optimize when deploying Analytics with Tag Manager results in an error

人盡茶涼 提交于 2020-01-14 09:18:39

问题


Update:

A/B tests are working fine.
Redirect tests are running but not reporting back.


I followed Google's article How to use Optimize when you deploy Google Analytics with Google Tag Manager, but I keep getting an error on Google Optimize:

Something seems wrong. Your experiment is running but hasn't received visits.

I used the Analytics debugger and everything seems fine, so I'm asking for your help.
Here's my setup:

<meta charset="utf-8">
<script>dataLayer = [...]</script>

//Page hiding snippet
<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-XXXXXXX': true});</script> //Optimize container id

//Requiring optimize in the analytics code, but not calling a pageview
<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-YYYYYYYYY-YY', {name: 'rollup', cookieName: '_rollupGa', allowLinker: true}); //Rollup analytics tracking id
  ga('rollup.require', 'GTM-XXXXXXX'); //Optimize container id
</script>

//Tag manager snippet
<script>
  (function (w, d, s, l, i) {
    w[l] = w[l] || [];
    w[l].push({
      'gtm.start': new Date().getTime(), event: 'gtm.js'
    });
    var f = d.getElementsByTagName(s)[0],
      j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
    j.async = true;
    j.src =
      'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
    f.parentNode.insertBefore(j, f);
  })(window, document, 'script', 'dataLayer', 'GTM-ZZZZZZ'); //Tag manager id
</script>

And here are my settings in Google Tag Manager:

An example of such web page: TAG Heuer Men's WAZ1110.BA0875 Stainless Steel Watch

Any help will be highly appreciated!


回答1:


Check for Analytics configuration mismatch. If for example, your GA code set an cookieDomain to a specific value and Optimize code to another, you may expect weird behavior.

All Analytics tracking code on your page must have the same tracker configuration settings. This is important a) if you use Google Tag Manager to fire Analytics hits, and you use hard-coded Analytics + Optimize code to deploy Optimize, or b) if you deploy Analytics and Optimize tags via Tag Manager. If you deploy Optimize via a Tag Manager tag, the best practice is to use the shared Google Analytics Settings variable in Tag Manager, which ensures your tracker settings match between tags.

Source: Installation diagnostics




回答2:


For my setup, where I deploy Google Optimize and Google Analytics via Tag manager I had to change the following settings and it worked (including redirect tests):

Optimize tag changes:

  1. Select the same Google Analytics Settings variable as the one used for Google Analytics Tag
  2. Remove any trigger you might have for the Optimize Tag
  3. Save

Google Analytics tag changes:

  1. Click Tag Configuration and then Advanced Settings and then Tag Sequencing.
  2. Under the Setup Tag, click the menu and select the Optimize tag.
  3. Under Fileds to Set section, be sure to configure 'cookieDomain' and set it to 'auto'.
  4. Save, preview and debug and go live if everything is fine


来源:https://stackoverflow.com/questions/43295591/running-google-optimize-when-deploying-analytics-with-tag-manager-results-in-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!