Skip to content

Instantly share code, notes, and snippets.

@wpflames
Created March 7, 2022 12:05
Show Gist options
  • Select an option

  • Save wpflames/782acbcb2ea913dcd0eaf1f014437a79 to your computer and use it in GitHub Desktop.

Select an option

Save wpflames/782acbcb2ea913dcd0eaf1f014437a79 to your computer and use it in GitHub Desktop.
Global tag
<?php
// =========================================================================
// ADD GOOGLE ANALYTICS GLOBAL TAG TO WP_HEAD
// =========================================================================
function add_global_tag_for_ads() {
echo '
<!-- Global site tag (gtag.js) - Google Ads: ************ -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW************script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
gtag("config", "AW-************");
</script>
';
}
add_action('wp_head', 'add_global_tag_for_ads');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment