【问题标题】:Google Analytics Goal Events using gtag code not working使用 gtag 代码的 Google Analytics(分析)目标事件不起作用
【发布时间】:2019-11-05 22:55:05
【问题描述】:

我尝试了许多不同的 gtag 和 ga 代码排列,但我似乎无法在 Google Analytics(分析)上获得积极的转化。

此代码在表单提交时运行,并且第一行中的 Google Ad 转换在该平台中注册了一次正转换。谷歌分析没有显示目标。

我没有使用 Google 跟踪代码管理器,但包含以下全局代码。

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'XXXXXXXX');
</script>

正如您在此处看到的,我标记为尝试的行如下:

// This Google Ad Conversion works properly
gtag('event', 'conversion', {'send_to': 'XXXXXXXX'});

// Attempt 1
gtag('event', 'Submit', { 'event_category': 'Form', 'event_label': 'Outdoor Kitchens Landing Oct 2019', 'value': 1 });

// Attempt 2
ga('send', 'event', 'Form', 'Submit', 'Outdoor Kitchens Landing Oct 2019', 1);

// Attempt 3
ga('send', {
  hitType: 'event',
  eventCategory: 'Form',
  eventAction: 'Submit',
  eventLabel: 'Outdoor Kitchens Landing Oct 2019',
  eventValue: 1
});

为了使 ga 代码正常工作,我必须在 HEAD 中包含以下 sn-p。

<script>
  window['GoogleAnalyticsObject'] = 'ga';
  window['ga'] = window['ga'] || function() {
    (window['ga'].q = window['ga'].q || []).push(arguments)
  };
</script>

Google Analytics 中的目标设置如下(被截断的标签为“Outdoor Kitchens Landing Oct 2019”

【问题讨论】:

    标签: google-analytics google-ads-api goal-tracking


    【解决方案1】:

    考虑添加gtag('config', 'UA-XXXXX-Y') 调用以启动分析跟踪并遵循有关分析事件跟踪的官方文档:https://developers.google.com/analytics/devguides/collection/gtagjs/events 从我在您的网站上看到的情况来看,分析跟踪器对象从未启动,因此没有数据发送到分析。 您需要为您使用的每项服务拨打gtag('config', ... ),例如一个用于广告转化,另一个用于分析:https://developers.google.com/gtagjs/devguide/configure 此外,您的 MonsterInsights 代码可能会影响跟踪,因此请检查它是否按预期工作。

    【讨论】:

    • 您将在该页面源代码的第 227 行看到 gtag 配置。它在 HEAD 中被调用。哦,我明白你在说什么。配置 GA 帐户。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 2023-03-09
    • 2019-07-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多