Facebook即时报道的观点未被Google Analytics统计

时间:2016-10-10 10:27:55

标签: wordpress google-analytics facebook-instant-articles

我想与您分享以下问题。我已经通过Instant Articles for WP插件在我的WordPress网站上实现了Facebook Instant文章。这些文章很好地出现在Facebook上,然而,谷歌分析并未记录对即时文章的跟踪。请帮忙,我在插件中使用的代码如下(代码添加在插件的'embed code'字段中:

<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>

我在互联网上研究过这个问题,但仍未找到解决方案,上面的代码建议在这里:

https://github.com/Automattic/facebook-instant-articles-wp/issues/321

该问题的另一个高度相关的主题是: How to track content Statistics for Facebook Instant Articles with Google Analytics

您是否有任何想法/改进建议如何通过Google Analytics工作获取即时文章跟踪?

感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

我的脚本如下所示:

<figure class="op-tracker">
  <iframe>
    <!-- Google Analytics Code -->
    <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-XXXXXXX-XX', 'auto'); // Replace with your Google Analytics Account
      ga('set', 'campaignSource', 'Facebook');
      ga('set', 'campaignMedium', 'Social Instant Article');
      ga('send', 'pageview', {title: 'POST TITLE'}); // Replace POST TITLE with real post title
    </script>
    <!-- End Google Analytics -->
  </iframe>
</figure>

请记住,您必须将其放入即时文章的正文部分。

答案 1 :(得分:0)

您还可以在javascript中映射到i3对象。该文档为here

ia_document

使用该模板,您可以将其映射到您的Wordpress Instant Articles设置中,如下所示:

<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>