India English
Kenya English
United Kingdom English
South Africa English
Nigeria English
United States English
United States Español
Indonesia English
Bangladesh English
Egypt العربية
Tanzania English
Ethiopia English
Uganda English
Congo - Kinshasa English
Ghana English
Côte d’Ivoire English
Zambia English
Cameroon English
Rwanda English
Germany Deutsch
France Français
Spain Català
Spain Español
Italy Italiano
Russia Русский
Japan English
Brazil Português
Brazil Português
Mexico Español
Philippines English
Pakistan English
Turkey Türkçe
Vietnam English
Thailand English
South Korea English
Australia English
China 中文
Canada English
Canada Français
Somalia English
Netherlands Nederlands

How to Add Google Analytics to WordPress

Are you looking for a guide on how to add Google Analytics to WordPress? Want to know how people find your website, which blog posts are the most popular, how many eCommerce transactions you’re making, how many of your visitors use mobile devices, and much more? 

By analyzing user behavior, you may optimize your website to increase traffic and revenue. What is the best part? All of the analytics data you require may be readily tracked and located with Google Analytics. 

In this article, we will show you how to add Google Analytics to your WordPress website.

What Is Google Analytics?

Google Analytics is a leading web analytics tool powered by Google, offering valuable insights into website traffic and audience behavior. This free service enables you to make data-driven decisions to strategically plan your website’s growth.

Google Analytics provides insights into:

– 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

Why Add Google Analytics to WordPress?

Adding Google Analytics to your WordPress site allows you to:

1). Visitor Tracking

Collect data on your site visitors, including geographic location, device, browser type, and more, helping you understand and target your audience effectively.

  2). User Behavior Analysis

Track how users interact with your site, which pages are popular, and where users drop off, allowing you to optimize the user experience.

3). Content Performance Tracking

Analyze the performance of your content, identify popular pages, and see how long users stay on them to create more engaging content.

4). Conversion Tracking

Measure your site’s success in achieving goals like sales, lead generation, or specific user interactions.

5). Ecommerce Analytics

For sites with e-commerce components, monitor transactions, product performance, and overall store effectiveness.

6). Custom Reports and Dashboards

Create custom reports to track key performance indicators (KPIs) relevant to your business, such as bounce rate, new users, and session conversion rates.

7). SEO Insights

Integrate with Google Search Console to monitor SEO performance, track keywords, and click-through rates, and identify SEO opportunities.

8). Audience Segmentation

Segment your audience based on characteristics, behaviors, or demographics to tailor marketing strategies.

9). Data-Driven Decision Making

Use detailed analytics data to inform decisions about your website, content strategy, and marketing efforts, helping you identify what works and what needs improvement.

Requirements for Adding Google Analytics to WordPress

Are you ready to add Google Analytics to your WordPress site? Here’s what you’ll need before you start:

1. A Google Analytics account.

2. A Google Analytics tracking or measurement ID.

3. Access to your WordPress admin dashboard.

Signing up for a Google Analytics account is straightforward. You can either create a new account specifically for your site or use an existing Google profile (such as one for Gmail) by signing in at [analytics.google.com](https://analytics.google.com) and associating it with your website.

How To Add Google Analytics to WordPress

There are several ways to add Google Analytics to your WordPress site. You can use WordPress’s Integrations tool, or a plugin, or manually insert the Google Analytics tracking code into your theme file.

The best method for you will depend on your WordPress plan. Don’t worry about editing your website’s code—it’s easier than it seems. 

Before you can connect Google Analytics to your WordPress site, you need to sign up for an account. The process is straightforward and only requires a Google account.

Step 1: Sign up for Google Analytics:

✔Launch Google Analytics Website

First, go to the [Google Analytics website](https://analytics.google.com). In the top right corner, click on Sign in to Analytics.

If you don’t have a Google Analytics account set up yet, click the blue Start for Free button.

a screenshot on creating google analytics account

✔Enter Your Email or Phone

After clicking the link, you’ll be taken to a screen where you can enter your Google account email address or phone number. Click Next to continue.

Make sure you enter the account associated with your Google Analytics. 

If you don’t have one yet, navigate to the registration page. Next, go to Google Analytics and click on the “Set up for free” button to start the process. On the “Create Account” page, enter your account name, set your Account Data Sharing Settings, and click “Next.” 

a screenshot of the first step of creating google analytics account

In the next section, select how you want to measure your site by choosing the “Web” option, then proceed to the following page. Enter your website details (name, URL, industry category, time zone, etc.) in the third section, and click “Create” once you’re done.

Google Analytics will then present its Terms of Service. Tick all the necessary boxes, and click the “I Accept” button. 

a screenshot showing google analytics terms of agreement

That’s it! You have successfully created a Google Analytics account.

✔Enter Your Password

Still on logging in the account, enter the password for your selected account. Click Next once you’re done.

If you’ve forgotten your password, use the Forgot password. Link to recover it.

You’ve now successfully logged in to your Google Analytics account. You can view various reports and access data to understand your users and check your site’s performance.

Step 2: Set Up a Property

The next step after creating a Google Analytics account involves setting up a property, that represents your website in Google Analytics:

1. Go to the Admin section and select Create Property.

2. Enter your website name and URL.

3. Choose your website’s industry, category, and reporting time zone.

a screenshot showing the second step of google analytics which create a property

4. Specify the currency for financial data reporting.

5. Follow the instructions to get your tracking code, which you’ll need to insert into your WordPress website.

Step 3: Configuring Your Data Stream

On the next screen, select the platform type relevant to the data you’ll be analyzing.

For a WordPress site, select “Web.”

a screenshot on options to choose a platform for google analytics account

If you have multiple websites or apps, you can add them to your property later.

Next, you’ll set up your data stream. In this context, a “data stream” or “web stream” refers to your website.

“https://” is selected by default. If your site doesn’t have a valid SSL certificate, use the drop-down to select “http://”.

Enter your website’s domain and name your data stream. Your stream name can simply be your domain name without the “.com” or something like “Business Name Website.”

If you have multiple websites or apps under the same property, ensure your stream names are distinct enough to avoid confusion.

“Enhanced measurement” is enabled by default, allowing GA4 to report on additional user interactions or “events” beyond the default actions tracked. This includes tracking scrolling behavior, file downloads, video engagement, in-site searches, outbound clicks, form interactions, and more detailed page view information. You can toggle this off if you prefer not to use it.

a screenshot on setting up a data stream for google analytics

When you’re ready, click “Create stream.”

Step 4: Finding Your Google Analytics 4 Measurement ID

The next step is to obtain the unique measurement ID provided by Google Analytics to integrate it into your website and start collecting data.

Your “Measurement ID” (or Google Tag) is a code that identifies your website or other data source.

After creating your data stream, you’ll land on the “Web stream details” page.

You’ll notice an alert at the top indicating that data collection isn’t yet active for your site. This is because you haven’t installed the Google tag on your WordPress site.

So, let’s do that.

Copy your “Measurement ID” to your clipboard.

Now that you have your Google Analytics tracking code, let’s add it to your WordPress site.

Step 5: Install Google Analytics  in WordPress

There are several methods to add Google Analytics to WordPress. 

Method 1: Google Analytics for WordPress by MonsterInsights

MonsterInsights is the most popular Google Analytics plugin for WordPress, used by over 3 million websites including Bloomberg, PlayStation, Zillow, and WPBeginner.

It is the easiest and best way to add Google Analytics to WordPress, suitable for both beginners and experts. MonsterInsights is available in both a paid premium version and a free version. In this tutorial, we’ll use the free version.

For advanced features like eCommerce tracking, ads tracking, and author tracking, you can use the MonsterInsights Pro version. The setup process is the same.

Getting Started

1. Install and Activate MonsterInsights
a screenshot of monsterinsights plugin

 First, install and activate the MonsterInsights plugin.

2. Launch the Setup Wizard

 After activation, a new menu item labeled ‘Insights’ will appear in your WordPress admin menu. Click on it and then click the ‘Launch the Wizard’ button.

a screenshot of launching the wizard

This will open the MonsterInsights setup wizard.

3. Select Your Website Category

 Choose a category for your website (business website, blog, or online store) and click ‘Save and Continue’.

a screenshot of categories for MonsterInsights plugin
4. Connect MonsterInsights to Your Website

Click the ‘Connect MonsterInsights’ button.

a screenshot of connecting MonsterInsights plugin

This will redirect you to Google accounts. Sign in or select your Google account.

Allow MonsterInsights to access your Google Analytics account by clicking the ‘Allow’ button.

5. Select Your Google Analytics Profile

Choose the profile you want to track and click the ‘Complete Connection’ button.

MonsterInsights will install Google Analytics on your website.

6. Configure Recommended Settings

 Use the default settings or adjust them as needed. If you use an affiliate link plugin, add the path to cloak affiliate links for tracking.

Choose which WordPress user roles can see the reports. Click ‘Save and Continue’ to save your settings.

7. Enable Tracking Features

Review the list of website tracking features and click ‘Continue’ or ‘Skip for Now’.

8. Complete Setup

MonsterInsights will confirm that Google Analytics tracking is successfully set up.

You can see that Google Analytics is connected, the tracking code is installed, and data is being collected.

9. Finish Without Upgrading

Scroll down and click ‘Complete Setup without Upgrading’ if you are using the free version.

Congratulations! You have successfully added Google Analytics to your WordPress website using MonsterInsights.

Method 2: Installing Google Analytics in WordPress Using WPCode

While not as comprehensive as MonsterInsights, this method allows the basic installation of Google Analytics without advanced tracking configuration or direct WordPress dashboard integration.

1. Copy the Google Analytics tracking code obtained during your account setup in Step 4.

a screenshot showing a measurement ID

2. Install and activate the WPCode plugin.

A screenshot showing the WPCode plugin

3. After activation, navigate to Code Snippets » Header & Footer. Paste your Google Analytics tracking code into the ‘Header’ section.

a screenshot of code snippets on WPCode plugin

4. Remember to click ‘Save Changes’ to apply your settings.

Congratulations! Google Analytics is now successfully installed on your site.

Method 3: Installing Google Analytics in a WordPress Theme

This method is intended for advanced users familiar with code. However, it comes with risks as the code may be lost during theme updates or switches.

We strongly advise against using this method in most cases.

If this is your first time adding code to WordPress files, refer to our guide on copying and pasting code snippets in WordPress.

1. Adding Code in header.php File

Edit the header.php file in your WordPress theme. Paste the Google Analytics tracking code immediately after the `<body>` tag.

Remember to save your changes and upload the file to your server.

2. Adding via Functions File

Alternatively, insert the Google Analytics tracking code into the functions.php file of your WordPress theme. This will automatically apply the tracking code to every page on your site.

Ensure to replace `’your Google Analytics code from Step 4 here’` with your actual Google Analytics code in the snippet above.

Conclusion

Google Analytics is a powerful, free web analytics tool that gathers vital data about your website’s performance and audience demographics. By leveraging these insights, you can make informed decisions to optimize and expand your WordPress site effectively.

We trust you found this guide helpful on how to add  Google Analytics to WordPress.

Author

× WhatsApp us