Skip to content

Instantly share code, notes, and snippets.

@danielmcclure
Created November 27, 2017 05:39
Show Gist options
  • Save danielmcclure/a22b13f92fdaaac2748fe9359222e215 to your computer and use it in GitHub Desktop.
Save danielmcclure/a22b13f92fdaaac2748fe9359222e215 to your computer and use it in GitHub Desktop.
Google Analytics Global Site Tag (gtag.js) for Facebook Instant Articles (Full Snippet)
<figure class="op-tracker">
<iframe>
<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>
</iframe>
</figure>
@danielmcclure
Copy link
Author

The link you shared is for Google Analytics 4. This gist is five years old and was correct at the time for GA Universal.

Thanks for sharing though!

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