[英]How to properly integrate Google Analytics in FB Instant Articles?
I am running Instant Articles For WP on my Wordpress site, at the moment all the traffic coming from Instant Articles isn't registering in Google Analytics. 我正在Wordpress网站上运行WP的Instant Articles ,目前所有来自Instant Articles的流量都未在Google Analytics(分析)中注册。
I did a little research and found that facebook allows the additional of 3rd party tracking codes . 我做了一点研究,发现facebook允许附加的第三方跟踪代码 。
I'm using the new gTag.js instead of the old method. 我正在使用新的gTag.js而不是旧的方法。
This is code is placed before </head>
这是放置在
</head>
之前的代码
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-MY-ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-MY-ID');
</script>
And this is the code in Instant Articles
Wordpress plugin, in the "Embed Custom Code" section. 这是
Instant Articles
Wordpress插件“嵌入的自定义代码”部分中的代码。
<figure class="op-tracker">
<iframe>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-MY-ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('create', 'UA-MY-ID', 'auto');
gtag('require', 'displayfeatures');
gtag('set', 'campaignSource', 'Facebook');
gtag('set', 'campaignMedium', 'Instant Article');
gtag('set', 'page_title', 'Instant Articles: '+ia_document.title);
gtag('send', 'pageview');
gtag('config', 'UA-MY-ID');
</script>
</iframe>
</figure>
Yet, I still don't see any campaigns being created in my analytics dashboard. 但是,我仍然看不到我的分析仪表板中正在创建任何广告系列。 I don't see the traffic coming from Instant Articles at all.
我根本看不到来自即时文章的流量。
The issue has been fixed. 该问题已解决。 I removed the HTML tags and fixed the parameters of
ga
to the following 我删除了HTML标签并将
ga
的参数固定为以下内容
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-MY-ID', 'auto');
ga('set', 'campaignSource', 'Facebook');
ga('set', 'campaignMedium', 'Facebook Instant Articles');
ga('set', 'referrer', ia_document.referrer);
ga('send', 'pageview');
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.