This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

How to Add Google Analytics to WordPress Websites

Updated on March 22, 2023

9 Min Read
google analytics wordpress

Successful marketing campaigns are based on data. If you have detailed data on your website visitors, you can customize your marketing campaigns to attract targets and convert them into leads.

Tracking visitors is an essential aspect of running an online business. Hence, there are many popular tools that help you track visitors and generate detailed segment reports on various web traffic analysis parameters. Among these tools, Google Analytics for WordPress is an excellent choice for analyzing visitor trends and traffic sources.

When you install Google Analytics on WordPress, you get detailed insights into your website and user behavior (such as page views, time spent on pages, bounce rate, traffic source, etc.). And experts recommend opting for the best WordPress hosting providers to use these insights for exemplary performance results.

Power up the Game of Hosting Today!

Discover a hosting revolution where downtime is a myth and customer support isn’t a punchline.

This article will discuss why you should use Google Analytics and the steps to set it up on your WordPress website.

Why Should You Set Up Google Analytics?

In this data-centric age, any tool that provides detailed information on website visitors is essential to your website. And a tool like Google Analytics that tracks visitors and their journey (such as search engines, ads, click-to-pay networks, email marketing, PDF, and onsite/offsite links) is a must-have for anyone seeking growth.

In particular, Google Analytics tells you:

  • Who visited your website and when
  • What visitors are doing on your website
  • How visitors discover your website
  • How visitors interact with your website content

Additional information includes visitor geo-location, browsers, default language, screen resolution, JavaScript support, etc. This user data is incredibly useful for developing strategies and helps you with website customization (such as theme and menu placement) and future website improvements.

How to Create a Google Analytics Account

Any user can easily install Google Analytics on a WordPress website regardless of their technical background.

You’ll find how easy the steps are as I demonstrate how to set up Google Analytics on WordPress websites.

Also, we have covered a detailed guide on integrating Google Analytics with WooCommerce.

So, let’s get started!

While there are many ways of integrating Google Analytics with WordPress websites, the steps mentioned remain the same for all methods.

Step 1: Create a Google Analytics Account

You need to create a Google Analytics account. For this, go to analytics.google.com. From there, two cases arise:

  1. You already have a Google account: Log in with your credentials.
  2. You don’t have a Google account: Create a new account by clicking the “Create account” button. Fill up the information, including your name, email address, password, and related information (date of birth, mobile number, location, etc.).
  • Once you’ve created your Gmail account, open the Google Analytics homepage and click the Start measuring button.

google analytics

  • You will see the Account Setup screen.
  • Fill in the account name and select the Account Data Sharing options.
  • Click Next.

analytics setup

  • You will see the property setup screen that lets you choose the reporting time zone, currency, and name.
  • Fill in the information and click Next.

google analytics property setup

  • You will see the About your Business form that asks you to select your industry category, business size, and the intent to use Google Analytics.

analytics about your business

  • Once you click the Create button, the Google Analytics Terms of Service Agreement popup will appear, prompting you to accept their terms and conditions.

google analytics terms

  • In data streams, choose your preferred platform to collect the data.

select web analytics

  • Set up the data stream by adding your Website URL and Stream name, then click on the Create Stream button.

google analytics data stream

  • You’ll see the Web Stream Details screen, showing that the web stream is created, but the data collection isn’t integrated and active, indicating you to install Google Tag on your WordPress site.

google tag

And here’s how you can add a Google tag:

Click the View Tag Instructions button, and you’ll see two ways to add the tag:

1) Install with a website builder or CMS.

2) Install manually.

When you add the tag to your website, Google will start tracking the data to your Analytics dashboard.

analytics installation

4 Easy Methods to Add Google Analytics to WordPress

You can install Google Analytics tracking code on your WordPress website via four different methods. I have listed all four below:

 Method 1: Add Google Tag Code to Header.php

You can add Google analytics to WordPress by simply copying/pasting the Tracking Code to your website code (in the “header.php” file).

add google tag

Follow the steps below:

  • Go to the WordPress Dashboard.
  • Click Appearance Editor.
  • Click the “header.php” file to edit its code.
  • Copy the “Tracking Code” from Google Analytics and paste it into the header code. Ensure to paste the code right before the </head> tag.

enter code in themes function

  • Once it’s done, wait for a few hours, as the installation can take up to 48 hours to fully activate.

analytics dashboard

Method 2: Install the Google Analytics WordPress Plugin

Installing Google Analytics via a plugin is an excellent alternative if your theme restricts you from using the first method.

The process requires installing a WordPress Google Analytics plugin. And since the WordPress plugin repository offers multiple solutions, I’ve mentioned the two best Google Analytics WordPress plugins to help you do the job without any fuss.

1. Google Analytics Dashboard for WP

GA Google Analytics is a simple, well-coded, and powerful plugin. Follow the steps below to install GA to your WordPress site.

  • Go to your WordPress Dashboard.
  • Click Plugins Add New.
  • Type “GA google analytics” in the search box.

ga analytics plugin

  • Click the “Install Now” button and then “Activate” the plugin.
  • Configure the plugin once it is activated.
  • Go to Dashboard Settings Google Analytics.
  • Click Plugin Settings.
  • Copy and paste the “Tracking ID” you find on the “Google Analytics Tracking Code” page (see previous screenshots).

ga tracking id

  • You must check the “Universal Analytics / analytics.js” and “Include tracking code in page head (via wp_head)” boxes that set up Google Analytics on the WordPress website.
  • Click the “Save Changes” button.

2. MonsterInsights

Google Analytics for WordPress by MonsterInsights is another popular Google Analytics WordPress plugin. It is a freemium plugin and is widely used because of its easy-to-use interface.

  • Install and activate the plugin by following the same steps shared in the previous method.
  • Navigate to the plugin’s settings page to link it with your Google Analytics account.

monster insights plugin

  • Click the “Connect MonsterInsights & Setup Web Analytics” button and run the MonsterInsights setup.

welcome monster insights

 

  • Select your site’s category.

category monster insights

  • I’m using a free version of MonsterInsights that doesn’t require any license. You can opt for the pro version if you want to enjoy the plugin’s premium features.

connect monster insights

  • Connect & authenticate your Google account with MonsterInsights.

connect and authenticate monster insights

  • After authenticating your Google account with MonsterInsights, click Save & Continue on the recommended settings & features screen.
  • Once the setup completes, the plugin takes a few minutes to fetch tracking data and displays the live tracking data in the WordPress dashboard.

analytics data

Note that a few options are restricted in the free version. But the pro version comes with options such as forms and multiple other features.

Method 3: Using Google Tag Manager

Another method to add Google Analytics to a WordPress website is using a Google Tag Manager. Follow the steps below:

  • Go to your WordPress dashboard.
  • Click PluginsAdd New.
  • Search for “google tag manager” in the text field.
  • Install and Activate the plugin.

google tag manager

  • Visit Google Tag Manager and click on the “Create Account” button if you have not already signed up.

create account on google tag manager

  • Enter the required details, including Account Name, Country, and Container Name, and click the Create button.

tag manager for web

  • Read the Google Tag Manager’s Terms of Service Agreement and mark the agreement to continue.

google tag manager terms

  • Once you complete the signup process, you will see the Google Tag Manager snippets.
  • Click the OK button to get your Google Tag Manager ID.

gtm id

  • Go back to the plugin’s settings, and paste your Google Tag Manager ID.
  • Click the Save Changes button.

gtm settings

  • Congratulations! You have successfully installed Google Analytics via Google Tag Manager.

Method 4: Hosting WordPress Google Analytics Locally

If you don’t prefer any of the three methods mentioned above, there’s another one for you: local hosting.

Google Analytics can be hosted locally on your server for better performance as it reduces external HTTP requests. To integrate this functionality, I will use a lightweight WordPress Google Analytics plugin, Complete Analytics Optimization Suite, developed by Daan van den Bergh.

Follow the steps below:

  • Head over to the WordPress dashboard.
  • Click Plugins, and search for “CAOS.
  • Install and activate the plugin.
  • Navigate to the plugin’s settings page.

caos plugin

  • Enter the Google Analytics Tracking IDe and select the location to place the tracking script.

google analytics tracking ID

Make Sure Google Analytics Works Well

Once you have integrated Google Analytics with your WordPress site, the next step is to verify the integration.

You can easily test the Google Analytics integration with your site by following the steps below:

  • Go to Google Analytics.
  • Click Real-TimeOverview.
  • Visit any page of your WordPress website.
  • If Google Analytics is connected to your website, you will see a bar indicating your website data goes back well in Google Analytics.

google analytics traffic overview

Note: It may take some time before the data is reflected in Google Analytics.

Wrapping Up!

This blog has shared the easy steps of setting up a Google Analytics account and integrating it with your WordPress website.

You can refine your site’s data analysis by editing Google Analytics’configuration options and creating different profiles by playing with filters, creating objectives, or even setting up events/tracking ecommerce.

These configurations will allow you to analyze traffic and help improve conversion rates. In case of any questions, do not hesitate to ask us for advice in the comment section.

Frequently Asked Questions

Q: How to add Google Analytics WordPress?

A: You can add Google Analytics to WordPress by setting up a Google Analytics account and pasting the tracking code inside your site’s header file. You can also add Google Analytics by using a plugin like GA Google Analytics or any other Analytics integration plugin.

Q: How to add the Google Analytics WordPress plugin?

A: Follow the steps below to add the Google Analytics WordPress plugin:

  • Go to your WordPress dashboard.
  • Click Plugins > Add New.
  • Search for the desired plugin.
  • Install and activate the plugin.
  • Navigate to the plugin’s setting page and connect it with your Google Analytics account.
Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Beautifully optimized hosting for WordPress and Magento”

Arda Burak [Agency Owner]

Farhan Ayub

Farhan is a community manager at Cloudways. He loves to work with WordPress and has a passion for web development. Mostly, he spends his time interacting with the people in the WordPress community. Apart from his work life, Farhan spends his time gaming and playing sports. Feel free to contact him at [email protected]

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Unleash The Cloud.
Not Budgets.

For 4 Months +
Up To 30 Free Migrations

Cyber Week

SAVINGS
Time Left In Offer
  • 0

    Days

  • 0

    Hours

  • 0

    Minutes

  • 0

    Seconds

40% OFF

On All Plans

GET THE DEAL NOW