1

I'm trying to track google analytics data for Author in Facebook Instant Articles (FBIA). Please see the comment in the example given below:

<item>
<title>
Article's Title
</title>
<description>Article's description</description>
<link>http://www.example.com/7216240</link>
<guid>7216240</guid>
<pubDate>Mon, 28 Aug 2017 10:31:50 +0200</pubDate>
<author>Author Name</author> // <-- This is the tag that I want to track in analytics
<content:encoded>
<![CDATA[
<!doctype html> <html lang="en" prefix="op: http://media.facebook.com/op#"> <head> ... </head> <body> <article> 
...
</article> </body> </html>
]]>
</content:encoded>
</item>

According to facebook for developers' documentation on Analytics for Instant Articles:

Facebook also exposes a defined set of Instant Article data, which the analytics trackers can use optionally. For JavaScript tracking codes, that data is available in the ia_document JavaScript object.

<figure class="op-tracker">
      <iframe>
          <script>
              // The URL the user shared
              var urlSharedByUser = ia_document.shareURL;

              // The article title
              var title = ia_document.title;

              // Referrer is always set to 'ia.facebook.com'
              var referrer = ia_document.referrer;
          </script>
      </iframe>
</figure>

However, it doesn't describe in detail which properties are inside the ia_document object.

A few Q&A on SO explain only with limited examples, something like

<figure class="op-tracker">
<iframe>         
<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-XXXXXXXX-X', 'auto');
  ga('require', 'displayfeatures');
  ga('set', 'campaignSource', 'Facebook');
  ga('set', 'campaignMedium', 'Social Instant Article');
  ga('set', 'title', ia_document.title);
  ga('set', 'referrer', ia_document.referrer);
  ga('send', 'pageview');

</script>
</iframe>
</figure>

Is there any article that explains Facebook Instant Article(FBIA)’s ia_document object (for analytics) and its properties in detail?

What else do we have other than ia_document.title, ia_document.shareURL and ia_document.referrer? in my case, do we have ia_document.author?

Aung Myo Linn
  • 2,820
  • 3
  • 27
  • 38
  • Log the whole `ia_document` object and inspect it …? – CBroe Aug 28 '17 at 09:40
  • @CBroe alright, is there any easy way to inspect Facebook Internal Browser? – Aung Myo Linn Aug 28 '17 at 09:43
  • Not really ... probably best if you loop over the object contents, and then output that as text content somewhere. – CBroe Aug 28 '17 at 09:44
  • @CBroe Could you kindly elaborate please? I'm not an expert in that context :) – Aung Myo Linn Aug 28 '17 at 09:50
  • https://stackoverflow.com/questions/684672/how-do-i-loop-through-or-enumerate-a-javascript-object ... just instead of console.log, you append to a string variable. – CBroe Aug 28 '17 at 09:52
  • Uh!, good point, I think I can also try `ga('set', ia_document)` instead, ref: https://developers.google.com/analytics/devguides/collection/analyticsjs/command-queue-reference – Aung Myo Linn Aug 28 '17 at 09:58

1 Answers1

2

Just figured out that there's a browser debugging tool which provides an approximation of the Instant Articles environment. So let me just answer my own question. The URL for the browser debugging tools is as below:

www.ia-tracker.fbsbx.com/instant_article_test?url=<share-url>

After testing it in a browser console, I can conclude that there are only 3 properties that belong to ia_document, which are ia_document.title, ia_document.shareURL and ia_document.referrer.

See the screenshot below: enter image description here

Aung Myo Linn
  • 2,820
  • 3
  • 27
  • 38
  • Hi @kolunar, thanks for debugging. According to the official Facebook docs, these three properties are the only ones available: https://developers.facebook.com/docs/instant-articles/analytics/#analytics-services. – natterstefan Jan 09 '19 at 08:22