Last active
May 8, 2025 19:49
-
-
Save Nicscott01/82d68284ac2466c0c4ea9a9b792e6314 to your computer and use it in GitHub Desktop.
Add a gtag to Google Tag Manager Code output by RankMath
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 | |
/** | |
* Add a gtag() line to an existing googletagmanager script | |
* that is installed by Rank Math SEO plugin. | |
*/ | |
add_filter( 'rank_math/analytics/gtag', function( $gtag ) { | |
$gtag['inline'] .= "gtag('config', 'AW-XXXXXXX');"; | |
return $gtag; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used this code to add a Google Ad tag to my website that's using Rank Math SEO for outputting Google Analytics.