How To Find the Tracking Code in Google Analytics
In order to get analytics from your WordPress page metrics you can use a free tool such as Google Analytics. The tool, along with Google Search Console, can be extremely helpful in analyzing things such as users, content, traffic, devices, locations, user behavior, Google Ads (if used), and more. But getting the code integrated is the first essential step to setting up Google Analytics.
There are a couple of ways to get Google Analytics working.
1. The first is taking the tracking code (a Javascript code within the <script></script> tags called Global Site Tag) and placing it into the <head></head> section of your header.php file. This can be done quickly through the Theme Editor (if you have a child theme enabled you need to select the parent theme in the dropdown). Or, you can edit the file using File Manager or through FTP. The only downside to this method is if you ever change your theme you will have to remember to add the Analytics code again because the header.php gets replaced with the new theme’s header.php.
2. The second option is to use a plugin like Google Analyticator. With this plug-in you can switch themes and Google Analytics will still work as long as you have the plug-in running. To use the plug-in you will take the Tracking ID found in Google Analytics and paste into the plug-in settings. Be sure to keep the plug-in updated.