SeedProd Logo

Latest SeedProd News

WordPress Tutorials, Tips, and Resources to Help Grow Your Business

How To Add Google To WordPress The Easy Way

How to Add Google Analytics to WordPress Websites 

Want to learn how to add Google Analytics to WordPress? Knowing why people visit your WordPress website and use your content is crucial for increasing your traffic and subscribers.

Analyzing your site’s statistics is the easiest way to learn more about your audience and the Google Analytics tool lets you do that for free.

This article will share why website analytics are important and how to set up Google Analytics in WordPress step-by-step.

What is Google Analytics, and How Does It Work?

Google Analytics is a free analytics solution that can track any type of website. It also offers a premium plan called Google Analytics 360 that starts from $12,500 per month and $150,000 per year.

Google Analytics 360 offers higher data limits, BigQuery integration, custom variables, service level agreement, and a dedicated support team. However, if you’re a small business, the free version of Google Analytics is more than suitable.

Learning about your website analytics is crucial for improving your website traffic. With more traffic, you can turn visitors into leads and subscribers, resulting in more revenue for your business.

By adding Google Analytics to WordPress, you can track the real-time data you need to gain insights for growing your business. It also helps you know what to do next and which digital marketing tactics to avoid when optimizing your site.

What Can be Tracked with Google Analytics?

With Google Analytics setup, you can collect metrics and statistics like:

  • Total number of website visitors
  • Where visitors come from
  • Which content is most popular
  • And much more

Here are several ways Google Analytics can help grow your business and improve your marketing strategy:

  • Learn More About Your Visitors: With Google Analytics for WordPress, you can collect crucial information about your website visitors, such as screen size, javascript support, geolocation, demographics, and more. You can then personalize your marketing strategy to fit their needs and interests.
  • Understand How Visitors Engage with Your Content: By adding Google Analytics to WordPress, you can learn what people are doing on your site. For example, you can see the pages they visit, how long they stay, their bounce rate, etc.
  • Learn How Visitors Find Your Site: Integrating Google Analytics with WordPress allows you to access tracking information about how visitors found your website. For instance, they may come from social media, the Google search engine, or another website referral.
  • Problem Solve When Things Go Wrong: When you add Google Analytics to WordPress, all your site’s data is at your fingertips in real-time reports. So if you notice any issues with your traffic or sales, you can find them and fix them fast to reduce lost revenue.

In the end, Google Analytics gives you all the information you need to make the right decisions to grow your business, with advanced options to test and optimize your site.

We’ll explain how you can sign up for Google Analytics before showing you how to set up Google on your website.

How Do I Get Google Analytics?

Before you learn how to set up Google Analytics on your WordPress website, you need to sign up for a Google Analytics account. Follow the steps below to learn how.

Step 1: Visit the Google Analytics Homepage

First, go to the Google Analytics homepage to sign up.

You’ll then see a popup where you can use your Gmail credentials to sign in if you already have a Google account.

Sign up for Google Analytics to learn how to add Google Analytic to WordPress

Otherwise, click the Create Account button to start a new account.

Next, you’ll see a welcome with an overview of what an analytics account can do for your business. Click the Set up for free button to get started.

Google Analytics welcome screen add google analytics to website

Step 2: Enter Your Account Details

The next screen asks you to enter an account name and choose your Account Data Sharing Settings. Click your preferred settings and click Next.

Google Analytics account data sharing settings

On the next screen, you can choose between adding:

  • Website
  • App
  • App and website

Choose the Website option and click Next.

Add a website to Google Analytics

Step 3: Enter Your Website Details

The next page is where you can create a Google Analytics property and enter the details for your sites, such as your property name, website URL, reporting time zone, and currency. You can track more than one website in Google’s analytics dashboard and pick a name appropriate for each site.

Enter your property details for Google Analytics

You’ll also see options for selecting an industry category and business size in the dropdown menu.

enter business information

Then, toggle the “Create a Universal Analytics Property” option to the ‘On’ position.

Create a universal analytics property

You also need to click the checkbox next to the bottom-left heading, “Create a Universal Analytics property only.” Otherwise, you may face issues connecting to MonsterInsights, which we’ll show you how to do later.

Now click Next.

Next, you’ll have to accept and agree to Google’s terms and conditions. So click, I Accept to move on.

Step 4: Copy Your Google Analytics Tracking Code

After that, you’ll see a screen with your Google Analytics Tracking ID and tracking code. Go ahead and copy your tracking code, as you’ll need to add it to your website, depending on which method you use below.

Google analytics global site tag and tracking ID

It’s a good idea to leave this page open in your web browser, as you may need to refer to it once you’ve installed the Google Analytics code on your website.

Now that you’ve set up your Google Analytics account let’s look at how to add Google Analytics to your website.

How to Add Google Analytics to WordPress?

There are several ways to add Google Analytics to your WordPress website. Below we’ll show you 5 different methods. The first method involves using a Google Analytics WordPress plugin, while the last is more difficult to achieve for beginners.

You’ll only need to use one of these methods to install Google Analytics in WordPress.

Method 1: How to Add Google Analytics to WordPress with MonsterInsights

MonsterInsights will help you understand how to add Google Analytics to WordPress

We’ll use a plugin to set up your tracking information for the first method. MonsterInsights is the best WordPress Google Analytics plugin and the easiest way to add Google Analytics to WordPress for beginners and experts.

MonsterInsights is super easy to use, and it only takes minutes to set up Google Analytics on your WordPress website. This powerful analytics plugin also has heaps of advantages over manual methods, including:

  • WordPress analytics reporting: Actionable website data and insights within the WordPress dashboard
  • eCommerce tracking: Set up tracking for WooCommerce, Easy Digital Downloads, LifterLMS, and MemberPress with 1 click
  • Affiliate tracking: Use Google Analytics reports in MonsterInsights to find out which affiliate links are getting the most clicks to maximize your revenue
  • Google AdSense tracking: Easily see who’s clicking your ads
  • Download monitoring: See how many downloads your files are getting with custom reports
  • Author stats: Find out traffic and engagement statistics for each author on your blog
  • Advanced Tracking: with optional Addons
  • Dual Tracking: Connect to Universal Analytics and Google Analytics 4 (GA4) simultaneously.

And you can do all this without knowing or understanding how to code, which can be tricky for small business owners.

Note: MonsterInsights used to be known as Google Analytics for WordPress by Yoast. WPBeginner’s founder, Syed Balkhi, acquired the plugin in 2016 and changed it to MonsterInsights. Now it’s part of their family of premium WordPress plugins.

Follow these simple step-by-step instructions to set up Google Analytics in WordPress with MonsterInsights.

Note: There is a free version and a paid version of MonsterInsights. For this guide, we’ll be using the paid version.

Step 1: Download and Install MonsterInsights

You can download Google Analytics for WordPress by MonsterInsights here if you haven’t already done so. Then save it to your computer and install and activate the plugin.

Install the MonsterInsights plugin by navigating to Plugins » Add New from your WordPress dashboard. Then click Choose Now to find the plugin .zip file on your computer and Install Now.

Step 2. Complete the Setup Wizard

After activating the plugin, you’ll see a new menu item called ‘Insights’ in your WordPress admin menu and a welcome screen. Click the ‘Launch the Wizard’ button to open the MonsterInsights setup wizard.

Launch MonsterInsights setup wizard to add Google Analytics to WordPress

On the next screen, you’ll need to choose a category for your website (such as a business site, blog, or online store). Choose one, then click the ‘Save and Continue’ button.

choose what to describe your website

Now you’ll need to connect MonsterInsights to your WordPress website.

Click on the ‘Connect MonsterInsights’ button to do this.

Connect MonsterInsights to your WordPress site

This option will take you to the Google accounts page where you can sign in or choose a Google account.

Select your Google account or enter your email address to sign in.

Choose a Google Account to sign in

Next, you will be asked to let MonsterInsights have read-only to access your Google Analytics account.

Click on the ‘Allow’ button to confirm this.

Allow access to your Google Analytics account

The following step to complete the connection is to choose the profile you want to track. So select your website here and click the ‘Complete Connection’ button to continue.

Connect analytics to your WordPress site

On the next screen, click the ‘Complete Connection’ button. MonsterInsights will now go ahead and install Google Analytics on your WordPress website.

Next, you’ll need to select the recommended settings for your website.

MonsterInsights recommended settings

The default settings are ideal for most websites., but you can customize them to suit your needs.

The plugin will also ask who can see your reports, so select the different WordPress user roles you prefer. After, click the ‘Save and Continue’ button to save your settings.

User roles settings

On the next screen, MonsterInsights will show a list of website tracking features you can enable.

Scroll down and click on the ‘Continue’ button or the ‘Skip for Now’ option.

Choose which tracking features to enable.

On the final screen, MonsterInsights will show you’ve added the Google Analytics tracking successfully.

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

Google analytics tracking is setup

When you scroll down, you’ll see a field to enter your license key.

Go ahead and paste the license key from when you created your MonsterInsights account and click the Verify License Key button.

Verify MonsterInsights license key

You have now added Google Analytics to your WordPress website.

Step 3. Set Up Event Tracking

The next step is to create a Measure Protocol API Secret. This will let MonsterInsights track events like eCommerce purchases, form conversions, and more.

To do this, log into your Google Analytics account, navigate to the ‘Admin’ settings page and click on the ‘Data Streams’ option.

Google Analytics data streams

When you see your data streams, select the website you used to connect with MonsterInsights.

Select a data stream

When the next screen appears, scroll down to the ‘Advanced Settings’ area and click the ‘Measure Protocol API Secrets’ option.

Select the measurement protocol API secrets options

Now you’ll see a new window with your Measurement Protocol API Secrets. This page will initially be empty, without any API secrets. So click the ‘Create’ button.

Create an API key

Next, enter a nickname for your API secret and click the Create button.

Enter an API name

Now you can copy the API secret under the ‘Secret Value’ field.

Copy API secret value

The next task is to enter the Secret Value in the MonsterInsights plugin.

You can do this by going to Insights » Settings from your WordPress admin and clicking the ‘General’ tab.

MonsterInsights general settings

Now go to the ‘Google Authentication’ section.

From there, you can enter the Secret Value under the ‘Measurement Protocol API Secret’ field.

Add measurement protocol api secret to MonsterInsights

The Measurement Protocol API Secret is now active on your website.

Now, let’s look at how to use dual tracking in MonsterInsights if you already have a Universal Analytics account.

Step 4. Set Up Dual Tracking for Universal Analytics

If you have a Universal Analytics account, then you can easily track Universal Analytics and Google Analytics 4 through MonsterInsights’ Dual Tracking feature. Plus, you won’t have to edit any code.

Note: Universal Analytics will sunset on July 1, 2023, meaning you won’t be able to track your site data after theat date. We recommend you set up a Google Analytics 4 property and start sending data to GA4.

To set up dual tracking, go to Insights » Settings from your WordPress dashboard and click the ‘General’ tab.

MonsterInsights general settings

Next, scroll down to the ‘Google Authentication’ section. Below the ‘Dual Tracking Profile’ field, you can enter your Univeral Analytics (UA) code.

Enter universal analytics tracking code

You can see your Universal Analytics code in Google Analytics by visiting the ‘Admin’ settings page.

Google Analytics admin settings page

Now you can click on ‘Property Settings’ under the Property column. When you do that, you’ll see the ‘Tracking Id’ in the following format: UA-XXXXXXXXX-X.

Google Analytics tracking id

You’ve now successfully started tracking Universal Analytics with Google Analytics 4 on your WordPress website. Remember, it will take Google Analytics a little time before displaying your statistics.

However, when your stats are ready, you can view your Google Analytics reports inside your WordPress dashboard. To do that, visit Insights » Reports to see a quick overview of your analytics data.

MonsterInsights dashboard reports

Method 2: How to Add Google Analytics to WordPress with WPCode Plugin

The following method isn’t as useful as MonsterInsights because you can’t use advanced tracking and see your analytics data in your WordPress dashboard.

First, copy the analytics tracking code you saved when setting up your universal analytics. You can find it in the Web stream details under the ‘Tagging Instructions’ section.

Copy the google analytics tracking code

Then install and activate the WPCode plugin on your website.

After activating the plugin, navigate to Code Snippets » Header & Footer from your WordPress dashboard. Then in the Header section, paste your Google Analytics tracking code.

Paste your google analytics tracking code into the header section

Finally, click the Save button. Now you’ve successfully added Google Analytics to your website!

Method 3: How to Add Google Analytics to WordPress with Google Tag Manager

Google Tag Manager is a tag management system (TMS) that lets you manage different tags on your website. It also helps you deploy different code types, like your Google Analytics tracking code, without having to edit your website.

Follow these simple steps to add Google Analytics with Google Tag Manager to your WordPress site.

Step 1: Create a Google Tag Manager Account

First, you need to sign up for Google Tag Manager and create a new account by entering an Account Name.

New Google Tag Manager Account

Now move on to the Container Setup. Enter your Container Name and your website, and select Web as your Target Platform.

Google Tag Manager container settings

Click Create to continue.

Now click yes to agree to Google Tag Manager’s Terms of Service. Then you’ll receive the tracking codes to add to your website.

Step 2: Add the Tag Manager Snippet to Your Header

The next step is simple. Copy and paste the code snippet into your header.php file in WordPress.

To do this, follow the steps we explained in Method 1.

Step 3: Add a New Tag in Google Tag Manager

To get Google Analytics connected to Google Tag Manager, start by clicking New Tag.

Add a new tag in Google Tag Manager to add google analytics

You can rename your tag if you’d like to, and click the Tag Configuration icon to choose your tag type.

add Google Analytics Universal Analytics to set it up in Google Tag Manager

Then choose Google Analytics: Universal Analytics.

Choose a tag type

You’ll have to enter your Tracking ID, which we explained how to find earlier, and your Tracking Type.

For this example, let’s choose the Pageview tracking type.

Pageview tracking type

Now, click the icon under the Triggering section to open up the page view settings.

You’ll need to choose the All Pages page view for adding Google Analytics.

add google analytics to tag manger with triggering settings

Now click Save, and you’re done!

This method is for users familiar with editing their site’s code. However, it’s an unreliable solution because the tracking code goes in your WordPress theme header. You’ll lose the changes you make if you update your WordPress theme.

First, you’ll need to copy your analytics tracking code and add the code to your theme files. There are 2 ways to do this, which we’ll highlight next.

But before you try these methods, you must make sure you’re using a WordPress child theme to make these changes. Otherwise, when you update your parent theme, you could overwrite your tracking info, resulting in your global site tag (gtag.js) being removed from your site.

Method 4: How to Add the Analytics Code in WordPress header.php File

To do this, you need to find the header HTML section of your site. In WordPress, this is your themes header.php file; you can find it by going to Appearance » Theme Editor.

Then scroll through the files until you find the right one and click to open and edit it.

Paste your Google Analytics tracking code into the file right before the closing </head> bracket, as shown below.

Where to put google analytics code in wordpress You can add Google Analytics to WordPress by adding the code to the header file

Then click Update File, and you’re done!

Method 5: How to Add Google Analytics Tracking ID to functions.php

Another way to a Google Analytics to WordPress without a plugin is to use the functions file. This will add your tracking id to every page of your website.

To find where to place your Google Analytics tracking code, locate your theme’s functions.php file. You can find it by navigating to Appearance » Editor from the WordPress dashboard.

Then scroll through your theme files until you locate the one labeled functions.php, which is your Theme Functions.

install Google Analytics to WordPress by adding it to theme functions file

Then add the following code snippet into the file using your tracking ID.

<?php

add_action('wp_head', 'sp_add_googleanalytics');

function

sp_add_googleanalytics() { ?> 

// Paste your Google Analytics tracking code from Step 4 here 

<?php } ?>

Click Update File when you’re finished, and Google Analytics should start working immediately.

How to View Your Google Analytics Reports

Now that you know how to connect Google Analytics to WordPress, you can start checking your data.

However, it takes Google time to collect and report the information through the Google Analytics dashboard.

So wait for at least 48 hours before looking at the collected Google Analytics data.

Once the waiting period is over, you can check your Google Analytics data by going to analytics.google.com. Then, you can even get a glimpse of your real-time stats, which you can use as part of your SEO strategy.

Some of the information you can gather includes:

  • Demographics – The age and gender of your audience
  • Geographics – Visitor languages, locations, and time zone
  • Behavior – New vs. returning visitors, frequency, engagement, and conversions
  • Search Console – Learn what people are typing into Google to find your site

But if you’ve used the manual method, you won’t be able to see any stats in WordPress. We suggest using method 1 to connect Google Analytics to WordPress with MonsterInsights.

Pro Tip: Google Analytics works more effectively with Google Search Console. It will help you see how your website search results are doing at a glance. See this Google Search Console guide to learn about using it to grow your website.

That’s it!

We hope this article helped you learn how to set up Google Analytics in WordPress easily.

If you liked this tutorial, you might want to check out our guide on how to put your WordPress site in maintenance mode so you can hide your site while making updates. And if you’d like to know how to add a contact form to WordPress, take a look at this tutorial.

Thanks for reading. Please follow us on YouTubeTwitter, and Facebook for more helpful content to grow your business.

Comments

Add A Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Get SeedProd

Join Our Newsletter

Subscribers to get Free WordPress Tips and Resources

We do not sell or share your information with anyone.

Let's Connect

Most Popular

Copyright © 2022 SeedProd LLC. SeedProd is a trademark of SeedProd, LLC

PayPal Verified Badge
WPBeginner Verified Badge