英文:
Next13 (App Directory) + Google Tag Manager + Google Analytics (Tags Not Firing)
问题
Struggling with integrating Google Tag Manager + Google Analytics Tag with Next 13 (App Directory). Not sure whether the problem is more with Next13 or with my Tag Manager setup (though there is not so much to set up, actually)
我在尝试将Google Tag Manager和Google Analytics标签集成到Next 13(应用目录)中遇到困难。不确定问题是与Next 13还是我的Tag Manager设置更相关(尽管实际上没有太多需要设置的内容)。
I have been following this tutorial. With this, am I supposed to activiate History Change Triggers in Google Tag Manager?
我一直在按照这个教程进行操作。根据这个教程,我是否应该在Google Tag Manager中启用历史更改触发器?
When I do send events via
当我通过以下方式发送事件时
event: 'pageview',
page: url,
})
I do see a pageview
event in my Google Tag Manager Preview, but my Google Analytics Tag isn't fired, even though I have it set to trigger on "All Pages". Any ideas?
我在Google Tag Manager预览中确实看到了pageview
事件,但是我的Google Analytics标签没有触发,尽管我已经将其设置为在“所有页面”上触发。有任何想法吗?
英文:
Struggling with integrating Google Tag Manager + Google Analytics Tag with Next 13 (App Directory). Not sure whether the problem is more with Next13 or with my Tag Manager setup (though there is not so much to set up, actually)
I have been following this tutorial. With this, am I supposed to activiate History Change Triggers in Google Tag Manager?
When I do send events via
window.dataLayer.push({
event: 'pageview',
page: url,
})
I do see a pageview
event in my Google Tag Manager Preview, but my Google Analytics Tag isn't fired, even though I have it set to trigger on "All Pages". Any ideas?
答案1
得分: 1
"use client";
import Head from "next/head";
import Script from "next/script";
import React from "react";
const GoogleTag = () => {
return (
<div>
<Head>
<meta
name="google-site-verification"
content="1jRUAxx6jZc-abqxxoa-rtI-6prcxxznoxxEKC6xxESTjxxq89FcIbg"
/>
</Head>
<Script
async
src="https://www.googletagmanager.com/gtag/js?id=xxxxxxxx"
strategy="lazyOnload"
/>
<Script
id="google"
dangerouslySetInnerHTML={{
__html: ` window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'xxxxxxxx');`,
}}
/>
</div>
);
};
export default GoogleTag;
英文:
I create components and use them in the main layout :
"use client";
import Head from "next/head";
import Script from "next/script";
import React from "react";
const GoogleTag = () => {
return (
<div>
<Head>
<meta
name="google-site-verification"
content="1jRUAxx6jZc-abqxxoa-rtI-6prcxxznoxxEKC6xxESTjxxq89FcIbg"
/>
</Head>
<Script
async
src="https://www.googletagmanager.com/gtag/js?id=xxxxxxxx"
strategy="lazyOnload"
/>
<Script
id="google"
dangerouslySetInnerHTML={{
__html: ` window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'xxxxxxxx');`,
}}
/>
</div>
);
};
export default GoogleTag;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论