Skip to content

Instantly share code, notes, and snippets.

@mbrughi
Created November 1, 2017 17:25
Show Gist options
  • Save mbrughi/32e1505dbdba194b8274d49a0203fc23 to your computer and use it in GitHub Desktop.
Save mbrughi/32e1505dbdba194b8274d49a0203fc23 to your computer and use it in GitHub Desktop.
Wordpress: insert Google Analytics code.
function my_google_analytics() {
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-69841290-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-69841290-2');
</script>
}
add_action( 'wp_footer', 'my_google_analytics' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment