Created
December 20, 2018 13:24
-
-
Save barzik/dce35bba7adad346c1a233893cb92c04 to your computer and use it in GitHub Desktop.
How to load Google Analytics without Google script with webpack
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
const analyticsId = 'XX-XXXXXX'; | |
window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args)); | |
ga('create', `UA-${analyticsId}-Y`, 'none'); | |
const gaLoader = document.createElement('script'); | |
gaLoader.src = 'https://www.google-analytics.com/analytics.js'; | |
gaLoader.async = true; | |
document.querySelector('head').appendChild(gaLoader); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment