Google Analytics Web+App 事件配置:错误“未定义 gtag" [英] Google Analytics Web+App event config: Error 'gtag is not defined'

查看:57
本文介绍了Google Analytics Web+App 事件配置:错误“未定义 gtag"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为网站设置 Google Analytics App+Web 的电子商务事件配置.请参阅此处的文档.

I'm trying to setup ecommerce event configuration of Google Analytics App+Web for a website. Refer to the documentation here.

因为电子商务配置有很多自定义代码,所以我不能使用通用的 GA App+Web webevent 模板,所以在这种情况下我使用自定义 HTML 标签.

Because there is a lot of custom code for the ecommerce configuration, I cannot use the general GA App+Web webevent template, so instead I'm using a custom HTML-tag in this case.

作为第一个测试,我尝试触发以下简单事件:

As a first test, I tried to fire the following simple event:

<script>

  gtag('event', 'blabla', {
  'test_param1': 'test_value_1'
});

</script>

但是,事件没有正确发送到GA;相反,控制台中返回以下错误:

However, the event is not correctly sent to GA; instead, the following error in the console is returned:

未捕获的引用错误:gtag 未定义

要复制,请参阅以下页面:https://www.hema.nl/mooi-gezond/make-up/make-up-accessoires/toilettassen-1/toilettas-11830901.html

To reproduce, see the following page: https://www.hema.nl/mooi-gezond/make-up/make-up-accessoires/toilettassen-1/toilettas-11830901.html

附加信息:

  • GA App+Web 基础初始化是通过 GTM(成功)通过 GA App+Webconfiguration 模板标签完成的.
  • 我还通过 GTM 通过 GA App+Web webevent 模板标签配置了一些其他(简单的非电子商务)GA App+Web 事件,并且这些事件已成功发送到 GA.

有谁知道出了什么问题,为什么会出现控制台错误以及为什么事件没有发送到 GA?

Does anyone know what's going wrong, why the console error appears and why the event is not sent to GA?

推荐答案

问题原因已经找到.问题似乎是,如果 App+Web 基础设置是使用 GTM App+Web 基础模板标签完成的,gtag() 将不起作用.相反,应首先将事件推送到 GTM 数据层,然后应使用 GTM App+Web 事件模板将事件发送到 Google Analytics.

The cause of the problem has been found. The problem seemed to be that gtag() does not work if the App+Web base setup is done with the GTM App+Web base template tag. Instead, an event should first be pushed to the GTM datalayer, and then the GTM App+Web event template should be used to send the event to Google Analytics.

非常感谢 Gino(在 Merkle 工作)解决了这个问题!

Lots of thanks Gino (working at Merkle) for fixing the issue!

这篇关于Google Analytics Web+App 事件配置:错误“未定义 gtag"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆