Skip to content

Instantly share code, notes, and snippets.

@chavesm
Last active March 17, 2021 09:03
Show Gist options
  • Save chavesm/3a3b95f381f4fe7ec558b0ec8e39c966 to your computer and use it in GitHub Desktop.
Save chavesm/3a3b95f381f4fe7ec558b0ec8e39c966 to your computer and use it in GitHub Desktop.
MonsterInsights Add GA4 Measurement ID for Dual Tracking (UA and GA4)
<?php
function monsterinsights_custom_add_ga4_tracking() {
echo "__gtagTracker( 'config', 'G-12345678' );"; // Change the measurement ID to yours.
}
add_action( 'monsterinsights_frontend_tracking_gtag_after_pageview', 'monsterinsights_custom_add_ga4_tracking', 15 );
/** Add to child theme's functions.php file. */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment