Google 跟踪代码管理器 - gtag() 事件自定义无法在 WordPress 网站上发送请求

问题描述 投票:0回答:1

我在 WordPress 网站上使用 Google 跟踪代码管理器时遇到问题,如果添加代码 gtag() 事件自定义无法发送“收集”请求,则会出现此问题。但如果使用 gtag('event', 'gtm.init') 正在工作,则已发送请求“collect”。

gtag('event','gtm.init')正在工作

gtag('事件',自定义)不起作用

但是如果使用“send_to:GA代码”有效

javascript wordpress google-tag-manager
1个回答
0
投票

您可以通过在 GTM 头代码上方添加以下行来重新启用 GTM 的 gtag:

window.dataLayer = window.dataLayer || [];函数 gtag(){dataLayer.push(arguments);}

请参阅 Google 的此页面:https://developers.google.com/analytics/devguides/migration/ecommerce/gtm-ga4-to-ua#4_enable_the_gtagjs_api

© www.soinside.com 2019 - 2024. All rights reserved.