Adding Google Analytics to WordPress is a painless process. There are numerous ways to do it. Today, we will follow some simple steps to get it added.
There is a plugin in the WordPress Plugin Repository that allows us to not only add the Google Analytics code, but load it in such a way that passes the Google PageSpeed Insights test.
By default, the Google Analytic’s script has a low 2 hour cache time set, which ironically triggers a flag in Google PageSpeed Insights.
The aforementioned plugin will let you add your Tracking ID, load the tracking code in the footer, and also load the script locally.
Loading the script locally bypasses the 2 hour cache limitation, removing the flag set by Google’s Page Speed test.
There is one caveat however, and that is that Google doesn’t support the local storage of the script.
The reason Google does not prefer the local serving of the script, is because it can quickly become out of date when upgrades occur.
However, the plugin that stores it, also leverages WP Cron to auto-update the script, so that concern becomes moot.
In this tutorial, you will learn:
- How to add your site to Google Analytics.
- How to connect Google Analytics with Google Search Console (assuming you have already added your site to Google Search Console).
- How to add Google Analytics to WordPress.
Resources mentioned in the tutorial:
Before you move on:
- Make sure that you have a Google Account. Having a Gmail email address or YouTube account qualifies.
- Make sure that you have already added your web site to Google’s Search Console. This process is covered in the video, but not below in the written instructions.
How to add your site to Google Analytics.
- Point your web browser to: google.com/analytics
- Click Sign In at the top right, then click Analytics. If prompted, login with your main Google Account.
- Click the Sign Up button.
- Type in an Account Name similar to the name of your web site.
- Type in your Website Name.
- Choose the protocol for your web site: http or https
- Paste in your Website URL.
- Choose an Industry Category that best matches what your site is about.
- Change the Reporting Time Zone to match your local time.
- Specify any Data Sharing Settings you are interested in. Read about them to see if they matter to you.
- Click the Get Tracking ID button.
- When prompted to accept the Terms of Service, choose your country, read the Terms, and if you accept, click the I Accept button.
- Copy your Tracking ID for later use.
Assuming you have already setup your web site within the Google Search Console, let’s move on to the next steps.
How to connect Google Analytics with Google Search Console.
- Click on Property Settings on the left side.
- Scroll down, and click the Adjust Search Console button, then scroll back up.
- Click the Edit link.
- Choose the preferred version of your site (with or without https, with or without www), then click the Save button.
- You will now land in the Search Console. You can close that window to go back to Analytics.
- Click the Done button. Refreshing the page will show the connection between Analytics and Search Console.
Now, with your Analytics Tracking ID handy, let’s go back to your WordPress Dashboard.
If you haven’t yet copied the Tracking ID, you can click the Tracking Info, then Tracking Code link in the Analytics Dashboard to get it.
How to add Google Analytics to WordPress.
- From within your WordPress Dashboard, click Plugins, then Add New.
- Do a search for: Complete Analytics Optimization Suite
- Click Install Now, then Activate.
- Click Settings, then Optimize Analytics.
- Paste in your Tracking ID in the top box.
- Choose Footer for the location, unless you have a specific reason to choose Header.
- Select Anonymize IP if applicable.
- Click the Save Changes button.
To test placement, you can either:
- Wait for Google Analytics to start reporting data. Visit your Google Analytics Dashboard to see. You can also have GA send test traffic.
- Or, enable the ‘Track logged in Administrators’ feature in the Complete Analytics Optimization Suite, then visit your site, right-click and View Source, then do a Find for your Tracking ID.
Leave a Reply