Mobile app version of vmapp.org
Login or Join
Angela700

: Facebook Instant articles' views not counted by Google Analytics I want to share with you the following issue. I have implemented the Facebook Instant articles on my WordPress website via the

@Angela700

Posted in: #GoogleAnalytics #Wordpress

I want to share with you the following issue. I have implemented the Facebook Instant articles on my WordPress website via the Instant Articles for WP plugin. The articles show up nicely on Facebook, however, the tracking of an Instant article does not get recorded by Google Analytics. Please help, the code I use in the plugin is as follows (the code is added in the 'embed code' field of the plugin:

<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','//www.google-analytics.com/analytics.js','__gaTracker');

__gaTracker('create', 'MyGAID', 'auto');
__gaTracker('set', 'forceSSL', false);
__gaTracker('send','pageview', {title: 'POST TITLE'});</script>


I have researched the issue on the Internet and still did not find the solution, the above code is suggested here:
github.com/Automattic/facebook-instant-articles-wp/issues/321
Another highly relevant topic to the issue is this one: How to track content Statistics for Facebook Instant Articles with Google Analytics

Do you have any ideas/improvement suggestions how to get the Instant Articles tracking by Google Analytics work?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

1 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi995

Google Analytics recently updated its tracking code to the Global Site Tag or gtag.js format. Below is the Google Analytics embed code for Instant Articles using gtag.js:

<figure class="op-tracker">
<iframe>

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());

gtag('set', 'page_title', 'Instant Articles: '+ia_document.title);

gtag('config', 'UA-XXXXXXXX-X');
</script>

</iframe>
</figure>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme