跟踪发送给客户端的流量

发布于 2025-01-15 14:30:44 字数 1597 浏览 1 评论 0原文

我有一个带有 Google Analytics 4 的新目录网站。

当有人单击将他们带到外部网站的链接时,我试图记录 website_click 事件。这是为了了解并报告我向这些客户端发送了多少流量。

不幸的是,我看不到正在记录的事件。我已尝试安装和使用 Google Analytics 调试器,但我在控制台中没有看到新的输出。

这是我正在使用的代码

 <head>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-HIDDENTAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-HIDDENTAG');
</script>
 <script>
    $( document ).ready(function(event) {
      $( ".link_to_provider" ).click(function(event) {
        event.preventDefault();
        setTimeout(visitProvider, 1000);
        var visited = false;

        function visitProvider() {
          if (!visited) {
            visited = true;
            window.open('https://www.example.com');
          }
        }

        // Sends the event to Google Analytics and
        // resubmits the form once the hit is done.
        ga('send', {
          hitType: 'event',
          eventCategory: 'provider',
          eventAction: 'website_visit',
          eventLabel: 'CID-10',
          hitCallback: visitProvider
        });
      });
    });
  </script>
  </head>
  <body>
  ....
                          <a href="https://www.example.com" rel="nofollow" class="link_to_provider"><button class="btn btn-primary px-4 mb-1 mt-0">Visit Website</button></a>
.....
  </body>

感谢您的帮助。

I have a new directory website with Google Analytics 4.

I am trying to record website_click events when someone clicks a link that takes them to the external website. This is to understand and report on how much traffic I am sending to these clients.

Unfortunately, I can't see the event being recorded. I have tried installing and using Google Analytics Debugger but I see no new output in my Console.

Here is the code I am using

 <head>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-HIDDENTAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-HIDDENTAG');
</script>
 <script>
    $( document ).ready(function(event) {
      $( ".link_to_provider" ).click(function(event) {
        event.preventDefault();
        setTimeout(visitProvider, 1000);
        var visited = false;

        function visitProvider() {
          if (!visited) {
            visited = true;
            window.open('https://www.example.com');
          }
        }

        // Sends the event to Google Analytics and
        // resubmits the form once the hit is done.
        ga('send', {
          hitType: 'event',
          eventCategory: 'provider',
          eventAction: 'website_visit',
          eventLabel: 'CID-10',
          hitCallback: visitProvider
        });
      });
    });
  </script>
  </head>
  <body>
  ....
                          <a href="https://www.example.com" rel="nofollow" class="link_to_provider"><button class="btn btn-primary px-4 mb-1 mt-0">Visit Website</button></a>
.....
  </body>

Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文