首页 > 解决方案 > 如何在 Angular js 中使用 Google Optimize 触发激活事件?

问题描述

我们在页面的标题标签顶部添加了谷歌优化狙击代码,我们还添加了 et headTag

<script>
  .async - hide {
    opacity: 0!important
  }
</script>

<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-XXXXX': true
  })
  ';
</script>

<<script>https://www.googletagmanager.com/gtag/js?id=UA-XXXXX</script>

  <script>
    window.dataLayer = window.dataLayer || [];

    function gtag() {
      dataLayer.push(arguments);
    }
    gtag('js', new Date());
    gtag('config', 'UA-XXXXX ', {
      'optimize_id': 'GTM-XXXXC'
    });
  </script>

标签: javascriptangularjssingle-page-applicationanalyticsgoogle-optimize

解决方案


推荐阅读