Skip to content

Instantly share code, notes, and snippets.

Created November 27, 2017 05:41
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Google Analytics Global Site Tag (gtag.js) for Facebook Instant Articles
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src=""></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('set', 'page_title', 'FBIA: '+ia_document.title);
gtag('set', 'campaignSource', 'Facebook');
gtag('set', 'campaignMedium', 'Social Instant Article');
gtag('config', 'UA-XXXXXXXX-X');
Copy link

hackhat commented Aug 22, 2018

Not working

Copy link

samitny commented Dec 19, 2018

Not working here either.

Copy link

Same, not working

Copy link

adamlytics commented Jan 15, 2019

Check this out:

Do it this way:
gtag('set', 'campaign', { medium: '', source: '', name: '', content: '' }); // code to send pageview / event

Or if you are doing this with the initial page view:
gtag('config', ''UA-XXXXXXX-X', { campaign: { medium: '', source: '', name: '', content: '' } );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment