Last active
November 22, 2023 20:34
-
-
Save kbcarte/4b519b3bdc98a358da515a07da6d0acc to your computer and use it in GitHub Desktop.
WordPress insert into head and body (GTAG, Analytics)
This file contains hidden or 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
<?php | |
// Insert code snippits to the <head> and <body> tags | |
// Useful for gtag and analytics | |
function insert_in_head() { | |
?> | |
<!-- Google Tag Manager --> | |
<!-- SCRIPT FOR GTAG --> | |
<!-- End Google Tag Manager --> | |
<?php | |
} | |
add_action('wp_head', 'insert_in_head'); | |
function insert_in_body() { | |
?> | |
<!-- Google Tag Manager (noscript) --> | |
<!-- SCRIPT FOR GTAG:NOSCRIPT --> | |
<!-- End Google Tag Manager (noscript) --> | |
<?php | |
} | |
add_action( 'wp_body_open', 'insert_in_body' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment