Google analytics 如何使用新的gtag代码跟踪Google Analytics中基于js的链接
我以前在我的谷歌分析中跟踪点击打开标签/模态等。后来我不得不改用新的gTag代码,js链接现在没有被跟踪。我怎样才能解决这个问题Google analytics 如何使用新的gtag代码跟踪Google Analytics中基于js的链接,google-analytics,Google Analytics,我以前在我的谷歌分析中跟踪点击打开标签/模态等。后来我不得不改用新的gTag代码,js链接现在没有被跟踪。我怎样才能解决这个问题 <script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxx-5"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLay
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxx-5"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
// line below previously pushed js links events
gtag('event', 'pageview', { 'page': location.pathname + location.search + location.hash});
gtag('config', 'UA-xxxxxxx-5', {
'linker': {
'domains': ['example.org.au']
}
});
window.dataLayer=window.dataLayer | |[];
函数gtag(){dataLayer.push(参数);}
gtag('js',新日期());
//前面推送的js链接事件下面的行
gtag('event','pageview',{'page':location.pathname+location.search+location.hash});
gtag('config','UA-xxxxxxx-5'{
“链接器”:{
'域':['example.org.au']
}
});
我解决了这个问题
要获取页面加载时包含锚定的完整路径,请执行以下操作:
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxx-5', {
'page_path': location.pathname + location.search + location.hash,
'linker': {
'domains': ['example.org.au']
}
});
</script>
link = location.pathname.replace(/^[\/]/, '') + location.search + location.hash
gtag('event', 'page_view', {'page_path': link});