我的自定义GA4事件在我将GTM添加到我的网站后停止发送。

huangapple go评论63阅读模式
英文:

My custom GA4 events stopped sending after I added GTM to my website

问题

我们的SPA中有一个硬编码的GA4标签。我们一直成功地使用window.gtag('event', eventName, {...})方法发送自定义事件。我们有数百个这样的自定义事件,由嵌入到代码中的应用程序逻辑触发。

最近,我们添加了GTM以添加其他第三方标签。但我们保持了GA4独立于GTM,因为我们需要在GTM仪表板上重新配置所有这些自定义事件,并为已经正常工作的内容做很多工作。

问题是:自从我们添加了GTM,我们的GA4自定义事件停止在GA4仪表板上收集。它们在GTM仪表板上也没有显示。我尝试将GA4标签添加到GTM以确保,但也没有帮助。

问题:如何让GTM和GA4独立共存,仍然可以收集我的现有GA4自定义事件(gtag('event', ...))?

注意:如果建议这样做,我愿意从我的代码中删除硬编码的GA4标签,并将其迁移到GTM,如果有办法让我继续使用我的gtag事件而不必在GTM UI上做大量工作。

如果我提问不够清楚,对不起,我还是一个GA的新手。

英文:

We have an SPA with a hardcoded GA4 tag. We have been successfully using the window.gtag('event', eventName, {...}) method to send our custom events. We have hundreds of such custom events that are triggered by app logic baked into the code.

Recently we added GTM to add other 3rd party tags onto it. But we kept GA4 independent from GTM because we would have to reconfigure all those custom events on the GTM dashboard, and do a lot of work for something that already works.

Problem is: our GA4 custom events stopped being collected on our GA4 dashboard since we added GTM alongside it. They don't show on the GTM dashboard anywhere either. I have tried adding the GA4 tag onto GTM for good measure, and that didn't help either.

Question: how can I have GTM & GA4 coexist independently, and still have my existing GA4 custom events (gtag('event', ...)) be collected?

Note: If advised, I am willing to remove the hardcoded GA4 tag from my code and migrate it onto GTM, if there is a way for me to keep using my gtag events without having to do a ton of work on the GTM UI.

Sorry if I suck at asking this question. I'm still a newbie in GA.

答案1

得分: 1

根据Tony的指示,您确实不希望在同一页面混合使用gtag调用来源。要么选择GTM,要么选择gtag.js。最佳实践是选择GTM,以便将所有分析逻辑集中在一个地方,因此真正的解决方案正是您所避免的。您的gtag()实现目前只是技术债务。

如果您想要将分析数据保留在两个地方,那么首先确保GTM没有激活ga4标签,然后去调试您在控制台/网络标签中的gtag调用,以查看发生了什么。还要查看您的gtag.js库的加载情况。

如果这些步骤无法解决问题,那么请添加屏幕截图和调试描述。

英文:

As Tony indicated, you really don't want to mix gtag calls sources on the same pages. Either go with GTM or gtag.js. And the best practice is to go with GTM to keep all your analytics logic in one place, so really the proper solution is exactly what you're avoiding. Your gtag() implementation is just a tech debt at this point, really.

If you want to keep your analytics in two places then what you want to do is first make sure GTM has no ga4 tags active, then go and debug your gtag calls in the console/network tab to see what's happening. As well as the loading of your gtag.js library.

If these steps won't make the issue apparent, then add screenshots and description of your debugging.

huangapple
  • 本文由 发表于 2023年5月17日 21:17:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76272546.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定