Are you looking for a way to automatically include Google Analytics code? While there’s probably a plugin for this, we have created a quick code snippet that you can use to automatically include Google Analytics code in WordPress.
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin, then be sure to replace the
UA-XXXXXXX-X in line 9 with your own Google Analytics tracking code.
If you liked this code snippet, please consider checking out our other articles on the site like: How to Install Google Analytics on Your WordPress Site and how to set up author tracking in WordPress with Google Analytics.