Three Ways to Add GA4 to WordPress
Official Site Kit plugin, manual functions.php code, or Google Tag Manager — each has tradeoffs.
💡 Skip tracking admin visits: wrap your GA4 code with
if (!current_user_can('manage_options')).Manual functions.php Method
function add_ga4_tracking() {
$id = 'G-XXXXXXXXXX';
echo "<script async src='https://www.googletagmanager.com/gtag/js?id={$id}'></script>";
}
add_action('wp_head', 'add_ga4_tracking');