How to track content Statistics for Facebook Insta

2019-01-13 19:45发布

Hello we have setup the Facebook Instant Articles feeds in facebook.

Facebook's Instant Article feature for publishers (rolled out on FB iOS apps mostly for now 30 3 2016) allows tracking by Google Analytics code. However, even after implementing GA code as instructed, we are not able to locate the referral or other info of FB Instant Articles in GA. Can anyone help me understand where exactly to find information in GA about content consumption on Facebook Instant Articles?? Will it appear as a referral source or a hostname? Instant Articles open inside FB.

7条回答
Viruses.
2楼-- · 2019-01-13 19:47

Unfortunately the other answers all involve some kind of mess that will likely confuse people. Here's an attempt at a solid, modern solution that uses UNIVERSAL ANALYTICS (the new one) rather than "ga.js" (the old one, though there is an even older one urchin.js that no one uses anymore).

<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', 'YOUR_UID_REPLACE_THIS', 'auto');
  ga('require', 'displayfeatures');
  ga('set', 'campaignSource', 'Facebook');
  ga('set', 'campaignMedium', 'Social Instant Article');
  ga('set', 'title', ia_document.title);
  ga('send', 'pageview');

</script>
  • YOUR_UID_REPLACE_THIS: Obviously put your personal GA code here.
  • campaignSource: Shows up as "Source" in GA.
  • campaignMedium: Shows up as "Medium" in GA.
  • ia_document.title: This uses the FB javascript variable for title.

So far for me the title gets successfully replaced for me with this code.

I had some very confusing experiences trying to test this with the "REAL-TIME" report on Analytics, where multiple posts were showing up with the same title, but overall I think it's working.

  • To test the 'title' field: REAL-TIME > BEHAVIOR
  • To test the 'Source' and 'Media' fields: REAL-TIME > TRAFFIC SOURCES

To see the traffic under the Acquisitions section of GA, go to Acquisitions > Source / Medium where it will be listed along with other sources (including several different ones from facebook).

FLAW (shared with all the other solutions) - Unfortunately my solution doesn't get IA traffic to show in the Acquisitions > Social > Facebook report. Even worse, it doesn't even show in the Acquisitions > Social report. Sadly, it gets lost in Acquisitions > Other, and for most of us, will mean a totally messed-up Social report overall.

  • The "Social" channel, like other channels, has a very precise set of source / medium values that it will filter into the different categories like Facebook.
  • Clearly, Facebook / Social Instant Article isn't on that list.
  • See This other StackOverflow post I made about this particular issue for more details. I will update my example here with whatever turns out to be the best practice.

Source for ia_document.title code: https://developers.facebook.com/docs/instant-articles/analytics

查看更多
地球回转人心会变
3楼-- · 2019-01-13 19:47

I'm using the solution below (a little bit different) and it's working perfectly.

<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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-9999999-9', 'mydomain.com');
ga('require', 'displayfeatures');
ga('set', 'campaignSource', 'Facebook');
ga('set', 'campaignMedium', 'Social Instant Article');
ga('set', 'title', 'My post title here');
ga('send', 'pageview');
</script>
</iframe>
</figure>
查看更多
Rolldiameter
4楼-- · 2019-01-13 19:50

According to their documentaion https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCampaigns#generalCampaign It is possible to set the source, medium and title through the analytics script. the title it is needed to be set given that the page title for the IA on the FB app is null.

PLEASE NOTICE THE CAPITAL LETTERS in the code are supposed to be updated with you static or dynamic values for it.

<figure class="op-tracker"> 
    <iframe hidden>
        <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','ga');
            ga('create', 'ANALYTICS ID', 'auto');
            ga('require', 'displayfeatures');
            ga('set', 'campaignSource', 'Facebook');
            ga('set', 'campaignMedium', 'Social Instant Article');
            ga('set', 'title', 'POST TITLE OR THE TITLE YOU WANT'); 
            ga('send', 'pageview');
        </script>
    </iframe>
</figure>

Again, Please Notice That THE CAPITALIZED WORDS are to be replaced by your actual values. Enjoy it.

查看更多
干净又极端
5楼-- · 2019-01-13 19:50

I've done it using dimensions, I think it is better practice, especially if you are tracking leads.

<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','//www.google-   analytics.com/analytics.js','ga');
            ga('create', 'ANALYTICS ID', 'auto');
            ga('require', 'displayfeatures');
            ga('send', 'pageview', {
               'dimension3': 'Facebook Instant Article'
            });
    </script>
  </iframe>
</figure>

Then create dimension3 in GA's admin and create a segment where dimension3 has the 'Facebook Instant Article' value. This way you can keep the campaign source & medium for their actual purpose.

查看更多
Melony?
6楼-- · 2019-01-13 19:54

I ran into the same issue. What works is this here:

URL to source of analytics code

If your analytics code can be served directly from a specific URL, you can specify the URL using the src attribute on the element.

<figure class="op-tracker">
    <iframe src="https://www.myserver.com/trackingcode"></iframe>
</figure>

(Source: https://developers.facebook.com/docs/instant-articles/reference/analytics)

The only thing that I do not know now is: If I use the extended Analytics code How to pull the Page Title?

查看更多
够拽才男人
7楼-- · 2019-01-13 19:58

Thanks for all the previous answers and solutions. They inspired me to summarize my learnings and solution in this public gist.

I am using Google's global site tag (gtag.js) to track the pageview and successfully attribute it to the Social medium in Google Analytics.

The following snippet illustrates what worked for me. Please note, we use jinja templates (with Nunjucks) to add the necessary and missing data (eg. {{googleAnalytics}}).

<figure class="og-tracker">
  <iframe>
    <script async src="https://www.googletagmanager.com/gtag/js?id={{googleAnalytics}}"></script>
    <script type='text/javascript'>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', '{{googleAnalytics}}', {
        'page_title': '{{articleTitle}}',
        'page_path': '/{{articlePath}}', // The path portion of location. This value must start with a slash (/) character. (optional, but recommended)
        'page_location': '{{articleUrl}}', // page's URL (optional, but recommended)
        'campaign': {
          'source': 'ia.facebook.com', // utm_source
          'medium': 'referral', // utm_medium
          'name': 'Facebook Instant Articles' // utm_campaign
        },
      });
    </script>
  </iframe>
</figure>

I embedded it like this in my feed

<figure class="op-tracker">
    <iframe src="https://www.example.com/fia-google-analytics-tracking.html"></iframe>
</figure>

Implementation Docs

查看更多
登录 后发表回答