How to Add Google Analytics to WordPress
Home About Portfolio Testimonials Blog Contact

The Web Dev Geek Blog

Your regular dose of geeky, businessy, websitey information

How to Add Google Analytics to WordPress

Introduction to Google Analytics

Google Analytics is a powerful tool for monitoring your website’s performance, visitor behaviour, and traffic sources. By integrating Google Analytics with your WordPress site, you can gain valuable insights that can help you optimise your content and improve your SEO strategy.

Creating a Google Analytics Account

  1. Visit the Google Analytics website (analytics.google.com) and sign in with your Google account.
  2. Click on ‘Start measuring’ to create a new account.
  3. Fill in your account name, and configure the data sharing settings according to your preferences.
  4. Click ‘Next’ to add a property. Enter your website name, select your reporting time zone, and choose your currency.
  5. After clicking ‘Next’, select your industry category and business size, then click ‘Create’. Agree to the terms of service, and your property will be created.

Obtaining Your Tracking ID

  1. Once your property is created, you’ll be directed to the property settings page. Look for the ‘Tracking Info’ option in the sidebar.
  2. Click on ‘Tracking Code’. Here, you’ll find your Tracking ID (formatted as UA-XXXXXXXXX-X) and the global site tag (gtag.js) code snippet.
  3. Copy the global site tag code. You will need to add this to your WordPress site.

Adding Google Analytics to Your WordPress Site

There are several methods to add Google Analytics to your WordPress site. You can use a plugin or manually add the tracking code.

Using a Plugin:

  1. Install and activate a Google Analytics plugin, such as ‘MonsterInsights’ or ‘Site Kit by Google’.
  2. Follow the setup wizard to connect your Google account and select the property you created earlier.

Manually Adding the Tracking Code:

  1. In your WordPress admin dashboard, navigate to ‘Appearance > Theme Editor’.
  2. Locate the ‘header.php’ file.
  3. Paste your global site tag code right before the closing </head> tag.
  4. Save your changes.

Verifying Your Setup

To ensure that Google Analytics is tracking your website correctly, go back to the Google Analytics dashboard. Click on ‘Real-time’ in the sidebar, and you should see active users on your site if you have visitors. Alternatively, you can use the Google Tag Assistant Chrome extension to verify the tracking code is installed correctly.

Conclusion

Integrating Google Analytics with your WordPress site is a crucial step in understanding your audience and improving your digital strategy. By following the steps outlined in this tutorial, you will be able to harness the power of analytics to drive better results for your website. Regularly check your analytics to gain insights and refine your content based on user behaviour.