Created
August 13, 2021 14:47
-
-
Save mbrughi/d189a45107297f013e727e8b19be7df5 to your computer and use it in GitHub Desktop.
Wordpress: add Google Analytics. (NB: please change UA-69841290-2 with your own Google Analytics Code)
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
/* | |
* Add Google Analytics | |
*/ | |
function mb_add_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> | |
<?php | |
} | |
add_action('wp_head', 'mb_add_analytics', 99); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment