How to Add Google Analytics to Facebook Instant Articles for WordPress

Facebook Instant Articles AnalyticsTo add Google Analytics to Facebook Instant Articles for WordPress then you will need to add some extra code to your website. The official Instant Articles for WP plugin allows you to add the snippet in your advanced settings. If you're not already using this plugin, then I highly recommend you do and set that up first. It may not be the highest rated plugin but it is the official plugin developed by Automattic (the commercial entity behind a lot of WP) and Facebook.

Once you have completed your initial setup you will need to click the subtle link pictured below to get to the advanced settings section and find the Analytics section.

Step One

Facebook Instant Articles Advanced Settings

Step Two

Google Analytics For Facebook Instant Articles

This is where you will be adding the extra code to enable Google Analytics for Instant Articles. Whilst you could simply drop in the standard Universal Google Analytics snippet here and it would “work”, there are a few optimisations that can improve the data you'll receive.

Here is the snippet you should actually use, making sure to replace the UA-XXXXXXXX-XX with the actual Tracking ID that you can find inside your Google Analytics Admin page under the Tracking Info heading.

Update: New Google Analytics gtag.js Version

One of the most important things about this Google Analytics snippet vs the standard one is that it also sets up a Campaign Source and Campaign Medium so you this can be broken out in your reports to differentiate from other traffic. Additionally it also sets up the page title for your reporting by hooking into a javascript variable provided by Facebook. Whether you understand the above or not, know that this is a good thing that will help the data make sense inside your Google Analytics dashboards and reporting.

The last step that you may need to complete is to head over to your Facebook Page's publishing settings (you may find this under your pages settings or in Business Manager) and refresh your Feeds. The path to these settings is:

  • Publishing Tools > Instant Articles > Configuration > Production RSS Feed
  • Publishing Tools > Instant Articles > Configuration > Development RSS Feed

It should look something like this:

Refresh Your Facebook Instant Articles

With this step complete, you should have successfully installed Google Analytics on Facebook Instant Articles for WordPress. Make sure you monitor your analytics and over time you should start to see Facebook Instant articles beginning to show up in your Google Analytics data.

Addendum: How To Manually Add Google Analytics for Older Instant Articles

If you add the Google Analytics code after your articles have already been submitted to the Facebook Instant Articles service then the code may not be be added to older posts. There are two ways that you can combat this:

  • Option 1: Head into your WordPress dashboard and make an edit to all of the articles that you wish to update. After this you can resubmit your feed to Instant Articles. Facebook will detect the changes and update your Instant Articles including the analytics code at the same time.
  • Option 2: Head to the Production Articles section of Instant Articles in your Facebook settings and manually add the code shown below (Note the additional figure and iframe tags). Make sure you remember to add your custom Tracking ID as described in the previous method.

Update: New Google Analytics gtag.js Version

Which method you use will depend on which version of the analytics snippet you use and how many articles you need to update. If you have thousands of posts then you may want to select your most popular evergreen content to get started or make the decision to focus on posts made after Instant Articles.

You may also want to review the official Instant Articles development documents for further information.  

 

 

12 thoughts on “How to Add Google Analytics to Facebook Instant Articles for WordPress”

  1. 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:

    https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X

    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’);

    More details on my blog post:
    http://jesscarranza.blogspot.com/2017/09/facebook-instant-articles-google-analytics-gtag-js.html

  2. Hi Ricardo, to find these stats within your analytics dashboard you would go into the “Acquisition” reports and you should be able to find them under the “Source/Medium” report filed as Source: Facebook and Medium: Social Instant Article. You might also want to set up a segment based on these filters to make it easier to call out this data when looking at your sites reports.

  3. Hi Daniel, I’ve installed the gtag.js code provided by Jess in the comments and in your post update, but I’m not yet seeing any activity reported in GA. FB is reporting traffic to my IA posts just fine.

    Any thoughts on what may be the issue or troubleshooting advice?

  4. Hi friends, can you help me with this code ? i put this into my instant article in footer block, but after i change my posts to instant article my statistics totally decrease, and i cant find anything like Instant Article in my google analytics dashboard, how can i see is it work or not ? and if it is not work how can i find where is a mistake ? sorry for my bad english.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top