WP Google Analytics
Use this to include your Google Analytics script in a WordPress child theme without tracking logged-in Admin users.
Install
Make an /inc folder in your child theme if one doesn't exist and place google-analytics.php within folder.
Next, we need to require the google-analytics.php file in your function.php file.
require_once( 'inc/google-analytics.php' );
Replace UA-XXXXX-Y with your own UA property.
Google Analytics 4
If using the new GA4, replace G-XXXXX with your own GA4 Measurement ID and uncomment line 18.