Created
November 27, 2017 05:41
-
-
Save danielmcclure/559c2fe2433035f72d80fe45755af7bf to your computer and use it in GitHub Desktop.
Google Analytics Global Site Tag (gtag.js) for Facebook Instant Articles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Global site tag (gtag.js) - Google Analytics --> | |
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script> | |
<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'); | |
</script> |
Check this out: https://stackoverflow.com/questions/50231721/how-to-track-utm-source-in-google-analytics-using-gtag
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
Same, not working