• Hi Team
    I added following code in Instant Article facebook plusgin’s analytic embed code section to track page view in GA.

    <figure class=”op-tracker”>
    <iframe>
    <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-61598488-1″></script&gt;
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(‘js’, new Date());

    gtag(‘config’, ‘UA-61598488-1’);
    </script>

    </iframe>
    </figure>

    but its showing Invalid HTML markup provided for custom analytics tracker code as an error

    Could anyone please help us in resolving this ASAp?

    TIA

Viewing 11 replies - 1 through 11 (of 11 total)
  • Rayna

    (@rayna)

    Hello,
    I have the same problem with Google Analytics.
    If someone could help us plz ?

    Thanks ??

    caouic

    (@caouic)

    Hi,
    Here is the code which works fine for my IA pages.
    In Embed Code of “Facebook Instant Articles Settings” set these lines:

    <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-XXXXXX-X', 'auto');
      ga('set', 'anonymizeIp', true);
      ga('require', 'displayfeatures');
      ga('set', 'campaignSource', 'Facebook');
      ga('set', 'campaignMedium', 'Social-Instant-Article');
      ga('send', 'pageview',{hitType: 'pageview', title: document.title});     
    </script>

    Hope it helps ??

    • This reply was modified 7 years ago by caouic.
    Thread Starter prateekbigreachio

    (@prateekbigreachio)

    Thanks Caouic

    Unfortunately, this is not working for us.

    Is there any other setting of instant article plugin that needs to be taken care of?

    caouic

    (@caouic)

    Hi @prateekbigreachio,
    Have you enable “Custom embed Code” in IA settings ?
    Have you a 3rd party plugin installed for Analytics ? (I don’t have one)
    In my code, you’ve to change ‘UA-XXXXXX-X’ by your own Analytics ID ‘UA-61598488-1’ in your case.
    If you use cache plugin, Try to purge cache.
    make a change in one of your post and check for changes in FB IA Pages Publication tools interface (5 – 10 minutes delay).
    regards,

    Thread Starter prateekbigreachio

    (@prateekbigreachio)

    Have you enable “Custom embed Code” in IA settings ? – yes
    Have you a 3rd party plugin installed for Analytics ? (I don’t have one) – no
    In my code, you’ve to change ‘UA-XXXXXX-X’ by your own Analytics ID ‘UA-61598488-1’ in your case. – did
    If you use cache plugin, Try to purge cache. – do not have cache plugin
    make a change in one of your post and check for changes in FB IA Pages Publication tools interface (5 – 10 minutes delay). – no resposne

    caouic

    (@caouic)

    When you edit your post have you IA warnings ?

    Thread Starter prateekbigreachio

    (@prateekbigreachio)

    No.

    caouic

    (@caouic)

    You are using gtag.js
    Maybe you can check in Google Tag Manager if you can use analytics.js

    Thread Starter prateekbigreachio

    (@prateekbigreachio)

    I added below code in analytics’s embed code section:
    <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&#8217;,’ga’);
    ga(‘create’, ‘UA-61954888-12’, ‘auto’);
    ga(‘require’, ‘displayfeatures’);
    ga(‘set’, ‘campaignSource’, ‘Facebook’);
    ga(‘set’, ‘campaignMedium’, ‘Social-Instant-Article’);
    ga(‘send’, ‘pageview’,{hitType: ‘pageview’, title: document.title});
    </script>

    Thread Starter prateekbigreachio

    (@prateekbigreachio)

    Awaiting your reply.

    caouic

    (@caouic)

    Hi,
    The code seems good.
    You can check your google analytics data if you receive data.
    Make a modification in one of your post and
    check your IA Pages in Facebook publication tools.
    The analytics code will be integrated.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘GA in Facebook Instant Article’ is closed to new replies.