How to add Google Analytics to WordPress

How to add Google Analytics to WordPress


Although Google Analytics is an essential tool for monitoring your WordPress site, the two platforms aren’t automatically connected. 

To add Google Analytics to WordPress, follow the three-step process below. We’ll give you two easy methods you can use to start tracking your website traffic.

Why You Should Use Google Analytics

Google Analytics provides valuable insights about what’s going on with your WordPress site. For example, you’ll learn about: 

  • The demographics of your visitors
  • The most and least popular pages on your site
  • How much time visitors spend on each page
  • How different user segments (like desktop vs. mobile users) engage with your site
  • Which websites, search engines, or social media platforms drive traffic to your site
  • How users flow from page to page
  • What kinds of events take place, like filling out forms and initiating checkout

You can also sync your Google Analytics account with Google Search Console to pull in SEO data related to keywords. 

While there are other ways to analyze what’s happening on your WordPress site, Google Analytics is the best solution. It’s free, easy to use, and it hooks right into the world’s most popular search engine. So the data you get from it is invaluable.

Step 1: Create a Google Analytics Account

If you’re new to Google, the first thing to do is create a Gmail address

With your new email address, you can now create a Google Analytics account. If you own multiple domains, you can use this single account to keep track of all of them. 

To get started, go to the Google Marketing Platform website. Click Get started today.

Create a new Google Analytics page from the Google Marketing Platform siteCreate a new Google Analytics page from the Google Marketing Platform siteCreate a new Google Analytics page from the Google Marketing Platform site

On the following screen, enter your Gmail address and the corresponding password. 

The next thing you’ll see is the Welcome to Google Analytics page. Click Start measuring to begin the process of setting up your account.

On the Welcome to Google Analytics page, click the Start measuring button to create your accountOn the Welcome to Google Analytics page, click the Start measuring button to create your accountOn the Welcome to Google Analytics page, click the Start measuring button to create your account

This five-step process should only take a few minutes to complete. Google will ask a number of questions about your business and website.

To create a Google Analytics account, there are five steps: Account creation, Property creation, Business details, Business objectives, and Data collectionTo create a Google Analytics account, there are five steps: Account creation, Property creation, Business details, Business objectives, and Data collectionTo create a Google Analytics account, there are five steps: Account creation, Property creation, Business details, Business objectives, and Data collection

Here’s what you’ll do to complete the setup: 

Step 1: Name your account

If you’re using Google Analytics as a business owner and want to monitor your own website, then name the account after your business or website. If you’re using Google Analytics as a web designer or agency and you’ll be using it to monitor clients’ websites, then name the account after your agency.

Step 2: Give your property a name

In Google Analytics, a property is a website or app. So enter the name of your website into this field. Then update the time zone and currency.

Step 3: Enter some business details about your business

Select an industry or category. Then choose your business size: Small, Medium, Large, or Very Large.

Step 4: Choose your business objectives

Choose an objective from the following: 

  • Generate leads
  • Drive sales
  • Raise brand awareness
  • Examine user behavior
  • Get baseline reports

On the Start collecting data screen, select the type of platform you want to monitor. For a website, select Web.

Choose from three peropty types to collect data: Web, Android app, iOS appChoose from three peropty types to collect data: Web, Android app, iOS appChoose from three peropty types to collect data: Web, Android app, iOS app

A new screen will open that asks you to Set up a data stream. This is your domain name.

To create a data stream on Google Analytics, enter your domain name into the empty fieldTo create a data stream on Google Analytics, enter your domain name into the empty fieldTo create a data stream on Google Analytics, enter your domain name into the empty field

Make sure to enter the domain name exactly as it’s written. So if there is a www. at the start, make sure to include it. 

Give the stream a name. Then click Create and Continue.

When you’re finished, Google will give you the tag for your property/website. 

After you set up a Google Analytics account, you'll receive a Google tag to use to connect WordPress to Google AnalyticsAfter you set up a Google Analytics account, you'll receive a Google tag to use to connect WordPress to Google AnalyticsAfter you set up a Google Analytics account, you'll receive a Google tag to use to connect WordPress to Google Analytics

Keep this screen open for the next step. If it accidentally closes, you can always retrieve the tag by clicking your web stream from the previous page or by opening the Google Tag Manager website.

Step 2: Add Google Analytics to Your WordPress Site

There are two different methods you can use to connect Google Analytics to your WordPress website. 

Method 1: Use a Google Analytics WordPress Plugin

If you do a search for “Google Analytics” in the WordPress plugin repository, you’ll find about a half a dozen to choose from. The best option from the bunch is MonsterInsights

In In WordPress, do a search for In In WordPress, do a search for In In WordPress, do a search for

To set it up, click the Install Now button and then Activate.

After MonsterInsights is activated, you’ll see a notice at the top of your dashboard asking you to connect your website.

From the Plugins screen in WordPress, set up your new MonsterInsights pluginFrom the Plugins screen in WordPress, set up your new MonsterInsights pluginFrom the Plugins screen in WordPress, set up your new MonsterInsights plugin

Click the button to begin the connection process. 

Go through the 5-step MonsterInsights setup process to add Google Analytics to WordPressGo through the 5-step MonsterInsights setup process to add Google Analytics to WordPressGo through the 5-step MonsterInsights setup process to add Google Analytics to WordPress

During this process, you’ll be asked to select your website type: Business Website, Publisher (Blog), or Commerce.

Unless you want to upgrade to the premium plugin, click Connect MonsterInsights on the next screen.

In the next step, you’re going to enable the plugin to grab the Google tag for you. To do this, click the Continue & Connect to Google button on the following screen.

The next thing you’ll see is the Google login screen. If you have more than one Google Analytics account, select the Gmail address for the one that corresponds with your WordPress site.

MonsterInsights will ask you to give them access to Google via the email you used to create your GA accountMonsterInsights will ask you to give them access to Google via the email you used to create your GA accountMonsterInsights will ask you to give them access to Google via the email you used to create your GA account

Click Continue to give Google permission to share this data. On the following screen, click Allow to give MonsterInsights access to your Google Analytics data.

If you have more than one property/website in Google Analytics, select the correct one from the dropdown.

Inside MonsterInsights, select the website you want to track data forInside MonsterInsights, select the website you want to track data forInside MonsterInsights, select the website you want to track data for

Then click Complete Connection

If you’d like to customize settings or access to the MonsterInsights plugin and data, do that on the following screen. Click Save and Continue when you’re done. 

You’ll also be able to activate additional features and tracking. For instance, if you have an ecommerce website, it would be beneficial to enable ecommerce tracking as well as advanced settings like conversion tracking. 

Click Continue or Skip for now. This wraps up the Google Analytics installation process. 

In addition to connecting Google Analytics to your site, you’ll now have the ability to see some of your Google Analytics data from within WordPress. Go to the MonsterInsights menu and click on Reports

Free MonsterInsights users have access to the Overview tab and basic data about website trafficFree MonsterInsights users have access to the Overview tab and basic data about website trafficFree MonsterInsights users have access to the Overview tab and basic data about website traffic

The only tab you’ll be able to see is Overview as a free user. But there’s enough in here to give you a bird’s-eye view of what’s happening with your website traffic. 

Method 2: Add the Google Tag to Your Header

Another way to set this up is to manually add the tag into the header of your website. 

What you need to do is grab the tag from the Google Tag Manager (or from the open window in Google Analytics).

Go to Google Tag Manager (or Google Analytics) to copy your Google tag for WordPressGo to Google Tag Manager (or Google Analytics) to copy your Google tag for WordPressGo to Google Tag Manager (or Google Analytics) to copy your Google tag for WordPress

Then paste the code into your website’s header.php file (just before the tag) or into the functions.php file. 

Typically, you’d have to log into your FTP or web hosting account to do this. However, there’s an easier way to get the Google Analytics tag in there and you won’t have to worry about theme updates interfering with or erasing the code. 

Using WPCode

One plugin that’s good for this is WPCode’s Insert Headers and Footers + Custom Code Snippets. Once it’s activated, go to the new Code Snippets menu on your WordPress sidebar.

In the WPCode plugin, you'll be able to add a new code snippet for Google AnalyticsIn the WPCode plugin, you'll be able to add a new code snippet for Google AnalyticsIn the WPCode plugin, you'll be able to add a new code snippet for Google Analytics

Click the Add New button. 

Select the Add Your Custom Code (New Snippet) box. 

In WPCode, create a custom code snippet. Give it a Google-related name and then paste in your Google tag.In WPCode, create a custom code snippet. Give it a Google-related name and then paste in your Google tag.In WPCode, create a custom code snippet. Give it a Google-related name and then paste in your Google tag.

Give the snippet a name — like “Google tag” — and then paste the code into the Code Preview box. Scroll down to make sure the Location under Insertion is set to Site Wide Header.

Then click Save Snippet.

Using Elementor Pro

Another quick way to insert the Google tag is by adding it to your page builder plugin. In Elementor Pro, for instance, you can add custom code to the header.

Go to Elementor and Custom Code. Click the Add New button at the top of the screen.

To add your Google tag to WordPress via Elementor Pro, use the Custom Code toolTo add your Google tag to WordPress via Elementor Pro, use the Custom Code toolTo add your Google tag to WordPress via Elementor Pro, use the Custom Code tool

Give the code snippet a name. Set the location to . Then paste your Google tag into the code editor. 

Click Save or Update to capture the changes.

Step 3: Confirm That the Google Tag Is Working Correctly

There are two things to check in this step. The first is to confirm that the tag has been detected on your WordPress site. The second is to confirm that it’s correctly pulling in data. 

Go back to the Google Analytics screen with your web stream data. Look at the top of the page. You’ll find one of two notifications there. 

If the tag can’t be detected, there will be a yellow notification box that reads: 

“Data collection isn’t active for your website. If you installed tags more than 48 hours ago, make sure they are set up correctly.”

In the Google Tag Manager, you'll see a yellow notification bar that reads "Data collection isn't active for your website. If you installed tags more than 48 hours ago, make sure they are set up correctly.” if the tag isn't workingIn the Google Tag Manager, you'll see a yellow notification bar that reads "Data collection isn't active for your website. If you installed tags more than 48 hours ago, make sure they are set up correctly.” if the tag isn't workingIn the Google Tag Manager, you'll see a yellow notification bar that reads "Data collection isn't active for your website. If you installed tags more than 48 hours ago, make sure they are set up correctly.” if the tag isn't working

If the tag can be detected, there will be a green notification box that reads: 

“Data collection is active in the past 48 hours.”

In the Google Tag Manager, you'll see a green notification bar that reads “Data collection is active in the past 48 hours.” if the tag is workingIn the Google Tag Manager, you'll see a green notification bar that reads “Data collection is active in the past 48 hours.” if the tag is workingIn the Google Tag Manager, you'll see a green notification bar that reads “Data collection is active in the past 48 hours.” if the tag is working

You may need to give it a couple days before Google can detect the tag. So return here at a later time if it’s not activated yet.

Once it is, go to the Google Analytics dashboard.

If your website is brand new, there probably isn’t going to be anyone on there now. So the easiest way to confirm that the tag is working is to look at real-time traffic.

From the left panel, select Reports and Realtime.

To confirm your Google tag, go to Google Analytics Realtime ReportsTo confirm your Google tag, go to Google Analytics Realtime ReportsTo confirm your Google tag, go to Google Analytics Realtime Reports

Now open your website in another browser and keep it open. The Realtime dashboard will show that someone is on your website. 

If it’s not working, then you’ll need to repeat Step 2. The issue could be if you used an alternative method to add Google Analytics to WordPress (some of those other plugins don’t work or cause other issues in WordPress). If the code wasn’t pasted in full, that could also cause issues.

So go over your work to confirm that everything looks good. Then come back here to see if Google Analytics can detect your activity. 

How to Add Google Analytics to WordPress

In this video tutorial, Envato Tuts+’s Adi Purdila shows you how to add Google Analytics to WordPress.


Conclusion

The process for adding Google Analytics to WordPress isn’t a complicated one. Start by creating a Google Analytics account for your property (or website). Then use the WordPress plugin of your choice to establish the connection. 

Now that you’ve learned how to bring Google Analytics and WordPress together, it’s time to familiarize yourself with your Google Analytics account. In this guide, you’ll discover how to get started with Google Analytics 4 and its most valuable features.



Source link