Amazon.co.uk Widgets

Log in

X
Site Kit for WordPress Google Analytics

A client had me set up Google Analytics on WordPress. I'm a Joomla guy. What could possibly go wrong?

TL:DR – Step by step setup of Google Analytics - GA4 - for a WordPress based website using Google SiteKit for WordPress

Step by Step Setup of Google Analytics for a WordPress-Based Website

1. Introduction

In today’s highly competitive digital landscape, website optimization isn't optional—it’s essential. Data is at the heart of this optimization, allowing businesses to make informed decisions that drive traffic, increase conversions, and improve user experience. Google Analytics is a powerful, free tool that can provide valuable insights into user behavior on your website. Setting it up correctly for your WordPress site ensures you make the most of your data, creating a clear path to greater digital success.

2. Prerequisites for Setting Up Google Analytics

Before diving into the setup process, ensure you have two crucial elements:

  • A Google Account: If you don’t already have one, create a Google account. This will serve as the foundation for your Analytics data.
  • WordPress Admin Access: You need administrative access to your WordPress site to install Google Analytics, either through manual code insertion or via plugins.

3. Creating a Google Analytics Account

Start by visiting the Google Marketing Platform analytics homepage and click 'Get started today'.

Get started today screenshot "Google Analytics gives you the tools, free of charge, to understand the customer journey and improve marketing ROI."
Get started today screenshot "Google Analytics gives you the tools, free of charge, to understand the customer journey and improve marketing ROI."

Then sign in with your google account.

Sign in to continue to Google Analytics (screenshot)
Sign in to continue to Google Analytics (screenshot)

Once logged in:

Google Analytics - Create an account (screenshot)
Google Analytics - Create an account (screenshot)
  • Click on the "Start Measuring" button to begin.
  • Create a name for your account. This could be your business name or site name. Accounts can access multiple data sources, using one or more measurement IDs.
  • Configure account data-sharing settings as needed, then click “Next.”

These initial configurations ensure that your Analytics data will be correctly attributed and stored under the right account.

4. Property Setup

When creating a new property, Google Analytics will  create a Google Analytics 4 property. Universal Analytics, the legacy version of Analytics, is no longer available here. Each property that you create holds all your measurement data for any selection of websites and apps that you choose.

Google Analytics 4 (GA4) property creation. This it the latest iteration of Google Analytics and offers more advanced features such as cross-platform tracking and machine learning insights.
Google Analytics 4 (GA4) property creation. This it the latest iteration of Google Analytics and offers more advanced features such as cross-platform tracking and machine learning insights.

Now describe your business in a bit more detail and click next. If you don't want to do this consider whether Google Analytics is right for you and your website needs as it is all about understanding your business.

Help Google to better understand your business by answering the following. Your input helps improve Google Analytics. (screenshot)
Help Google to better understand your business by answering the following. Your input helps improve Google Analytics. (screenshot)

Now choose your business objective

Google Analytics can prioritise reports that are personalised to your business, select the topics most important to you. (screenshot)
Google Analytics can prioritise reports that are personalised to your business, select the topics most important to you. (screenshot)

Accept the terms.

Google Analytics terms of use (screenshot)
Google Analytics terms of use (screenshot)

Once you’ve created the property, Google Analytics will provide you with a unique tracking ID (for example, UA-12345678-1). This identifier allows Google to collect and store data from your WordPress website. It is essential for linking your website to the Google Analytics platform, ensuring all visitor data is recorded.

5. Start collecting data

Choose a platform - Choose Web.

Start collecting data in Google Analytics (screenshot)
Start collecting data in Google Analytics (screenshot)

Set up data stream

Set up data stream in Google Analytics (screenshot)
Set up data stream in Google Analytics (screenshot)
  • Enter the URL to your website
  • Give the stream a name
  • Leave the default 'enhanced measurement' on

Set up a Google tag

Set up a Google tag (screenshot)
Set up a Google tag (screenshot)

View Web stream details

Google Analytics Web stream details (screenshot)
Google Analytics Web stream details (screenshot)

6. Installing Google Analytics on WordPress

There are two primary ways to install Google Analytics on a WordPress site:

  • Manual Integration: By adding the tracking code directly to your theme files.
  • Plugin Integration: Using a plugin to automatically insert the necessary code, offering ease and flexibility without touching code.

Manual integration is harder and assumes you know how to edit the code of your site and if you don't then you should use a plugun.

7. Manual Integration Method: Inserting Tracking Code

For manual integration, follow these steps:

  • Navigate to your WordPress dashboard, go to "Appearance" > "Theme Editor," and find the header.php file.
  • Paste the tracking code you generated in Google Analytics just before the closing </head> tag.
  • Save the changes. This method directly embeds the tracking code into your website's structure, ensuring data collection.

8. Installing Google Analytics Using a Plugin

Plugins offer a more user-friendly option. There is an official Google plugin, and other plugins are available.

Site Kit Google's official WordPress plugin (Screenshot0)
Site Kit Google's official WordPress plugin (Screenshot0)

Recommended plugins include:

  • MonsterInsights: A popular, intuitive plugin that integrates seamlessly with Google Analytics.

  • Site Kit by Google: Official Google plugin that provides analytics insights right in your WordPress dashboard.
    • Installation from within WordPress
      • Visit Plugins > Add New.
      • Search for Site Kit by Google.
      • Press Install Now then Activate the Site Kit by Google plugin.
        Install Site Kit by Google for WordPress – Analytics, Search Console, AdSense, Speed (Screenshot)
        Install Site Kit by Google for WordPress – Analytics, Search Console, AdSense, Speed (Screenshot)
        Press Start setup and Sign in with Google to connect Google analytics.
        Setup Site Kit by Google for WordPress – Analytics, Search Console, AdSense, Speed (Screenshot)
        Setup Site Kit by Google for WordPress – Analytics, Search Console, AdSense, Speed (Screenshot)
      • Connect Google Analytics as part of your setup. Activate Google Analytics to track how much traffic you’re getting and how people navigate your site. 
      • If there are multiple WordPress admins, keep in mind that each admin must connect their own Google account in order to access the plugin.
      • Optionally help improve Site Kit by sharing anonymous usage data.
      • Go to the main Site Kit dashboard which already displays key metrics from Search Console.
      • Optionally connect additional Google tools under Site Kit > Settings.

Once you're done you should see that Google Analytics is gathering data, and that it might take up to 72 hour before anything becomes visible.

Site Kit for WordPress Google Analytics is gathering data (screenshot)
Site Kit for WordPress Google Analytics is gathering data (screenshot)

9. Verifying Proper Installation

After completing the setup, it’s crucial to verify that Google Analytics is correctly tracking your site. Here are two ways to confirm:

  • Previously you could use the Google Analytics Debugger or Page Analytics (both by Google) extension in Chrome to check for errors in your tracking setup. These extensions however do not seem to support the latest version of Google Analytics (GA4) so should be avoided unless they are updated.
    Google Analytics Debugger "doesn't follow best practices for Chrome extensions" (Screenshot)
    Google Analytics Debugger "doesn't follow best practices for Chrome extensions" (Screenshot)
    Page Analytics (by Google) "doesn't follow best practices for Chrome extensions" (Screenshot)
    Page Analytics (by Google) "doesn't follow best practices for Chrome extensions" (Screenshot)
  • You might want to try Page Analytics: on-page SEO insights from GA4 and extension in Chrome to check for errors in your tracking setup
    Page Analytics: on-page SEO insights from GA4 (screenshot)
    Page Analytics: on-page SEO insights from GA4 (screenshot)
  • Alternatively go to Google Analytics and check the "Real-Time" report to see if your visits are being recorded live as you browse the site.

10. Configuring Basic Google Analytics Settings

Once you’ve verified proper tracking, fine-tune your analytics setup:

  • Excluding Internal Traffic: Ensure your own visits don’t skew your data by installing the extension Google Analytics Opt-out Add-on (by Google) or setting filters to exclude internal IP addresses
    • In Admin, under Data collection and modification, click Data streams.
    • Click a web data stream.
    • In the web stream details, click Configure tag settings.
    • Click Show all.
    • Click Define internal traffic.
    • Click Create.
    • Enter a name for the rule such as 'Internal'
      Enter a value for the traffic_type parameter or accept the defualt 'internal'
      In IP address, Match type,  choose IP address equals and add the external IP address of your internal network. Click help to find it or go to https://whatismyipaddress.com/.
      Create internal traffic rule for Google Analytice (screenshot)
      Create internal traffic rule for Google Analytice (screenshot)
  • Setting Up Goals: Configure goals, such as form submissions or product purchases, to track conversions and essential interactions.

These basic settings provide a decent representation of your visitors' behavior, but you can go into far far more detail if you like.

11. Advanced Setup Options

For users with more complex needs, advanced configuration options are available:

  • Enhanced eCommerce Tracking: For online stores, enabling eCommerce tracking provides granular insights into product performance, customer behavior, and checkout processes.
  • Cross-Domain Tracking: If you manage multiple domains or subdomains, cross-domain tracking ensures that user sessions across different properties are tracked seamlessly, giving a unified view of visitor activity.

12. Conclusion

Setting up Google Analytics is a critical first step in leveraging the power of data to drive your website’s performance. Beyond the initial setup, it’s important to regularly review and adjust your Analytics configuration as your website evolves. Ongoing analysis will help you optimize your content, improve user experiences, and ultimately achieve your business goals more efficiently.