Google Analytics(分析)事件跟踪-控制台错误

时间:2020-03-17 01:15:53

标签: javascript

我没有使用GoogleTag,而是直接使用Google Analytics(分析),所以一旦我将网站添加到Google Analytics(分析) 我从他们那里得到的代码如下:

   <!-- Global site tag (gtag.js) - Google Analytics -->
   <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXXXX-10"></script>
   <script>
   window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'UA-XXXXXXXXXXXXXX-10');
    </script>

然后我找到了一些教程,该教程解释了要创建一些事件,我需要使用ga('send'....。 ,因此在其中我希望有人访问该页面后触发该事件的测试页面之一:

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXXXX-10"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'UA-XXXXXXXXXXXXXX-10');
      ga('send', 'event', 'Test Event', 'Posted , Not Confirmed', 'Postings');
    </script>

如您所见,我在代码底部添加了ga('send...。 当我加载此页面时,控制台出现错误:

ga is not defined

请让我知道我在做什么错

0 个答案:

没有答案