为了更好地跟踪跨域 iframe,我想为 Google Analytics 的 gtag 手动设置 utm 参数。
我无法更改它添加 utm_source={source} 等的 url。
我的 iframe 加载如下:
<iframe src="https://example.com/?pagetest=a&source=source_page"></iframe>
然后在服务器端,我将提取这些参数,因此如果另一个父站点放置 ie referer_source 而不仅仅是源,我可以更改它,因此在 javascript 中所有变量都是相同的。
我找到了这个线程,但是它对我不起作用。这是标题中的脚本代码:
<script async src="https://www.googletagmanager.com/gtag/js?id={id}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{id}',{
'page_title':'title',
'page_referrer':'{ source }',
'page_location':'/current_page',
'page_path':'/current_page',
});
// Sends an event that passes 'age' as a parameter.
gtag('event', 'page_view', {'pagetest': 'a'});
</script>
我仍然将 iframe 的父域视为推荐,并且在事件选项卡中我只看到
事件类别:一般;事件动作:pagetest;事件:100%
我想对页面上的总数进行分析,然后能够在示例中分解 pagetest a 和 pagetest b。
如何在 javascript 中设置所有这些点?