Created
July 8, 2018 19:27
-
-
Save davestewart/f88e5e0d57882179bc19724a0e2c1718 to your computer and use it in GitHub Desktop.
Google Analytics - single file include
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
(function track (id) { | |
// prepare data | |
window.dataLayer = window.dataLayer || [] | |
function gtag () { dataLayer.push(arguments) } | |
gtag('js', new Date()) | |
gtag('config', id) | |
// load analytics | |
var script = document.createElement('script') | |
script.src = 'https://www.googletagmanager.com/gtag/js?id=' + id | |
script.type = 'text/javascript' | |
script.async = true | |
document.head.appendChild(script) | |
}('UA-XXXXXX-YY')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment