Download

How To Add Google Analytics To A WordPress Website In 2021

If you are new to the world of blogging, or just realized the need for website analytics, then you are in the right place.

This guide not only covers how to add Google Analytics to WordPress site but would also help you sign up for Google Analytics.

Website analytics is an important part of knowing the audience of your website. With the help of traffic stats, you can easily improve traffic, sales, and other key metrics of a business.

How to Add Google Analytics to a WordPress Website Without Plugin

There are various methods to add Google Analytics in a WordPress website. But I found the following 2 to be the easiest and quick for beginners.

  1. Method 1: Manually adding the code
  2. Method 2: Utilizing the power of Google Tag Manager

Method 1: Integrate Google Analytics and WordPress Manually with Code (Don’t worry you only need to copy-paste the code)

Step 1: Sign up for a Google Analytics account (FREE)

Step 2: Choose the type of property such as web or app

Step 3: Enter the details of your property

Step 4: Get the tracking code from the Google Analytics dashboard

Step 5: Go to the WordPress dashboard, and go to Appearance –>Theme Editor

Step 6: Locate header.php in the right side of the dashboard to copy and paste the code. (If your child theme is inheriting data from a parent theme you will not see header.php)

Step 1: Sign up for a Google Analytics account (FREE)

Signing up for Google Analytics is pretty easy and is free of cost. Just go to https://analytics.google.com/, and Click set up for free.

google analytics to wordpress

Step 2: Choose the type of property such as web or app

Add an account name of your website and make sure to check all the data sharing options, and Click Next.

Step 3: Enter the details of your property

In this step, you have to again add the name of your website as the Property name, Reporting time, and the currency your business operates in.

This will help you generate reports according to your time zone and currency, which can help you take rightful business decisions.

Now Click on “Show advanced options”, in order to set up the Universal Analytics Property for your website.

If you are going to skip this step, Google will automatically install the new GA-4 version on your website. (this is not yet recommended due to complications in installing and data collection).

Google Analytics 4 is a new version of Analytics by Google. This is backed by AI-powered insights and provides more granular data i.e. more detailed website analytics for you to improve your business.

Now in the advanced options, type your website URL and select Create a Universal Analytics property only, as shown below, and click Next.

In the next window, you will have the option to select a few more things related to your business. This includes Industry, Business size, and how are you planning to use Google Analytics with your business.

You can choose what applies to your business and Click Create to add a new property in Google Analytics.

Step 4: Get the tracking code from the Google Analytics dashboard

In the next window, you will see the tracking code and the tracking ID for your Analytics Account as shown below in the screenshot.

Step 5: Go to the WordPress dashboard, and go to Appearance>Theme Editor

We are just a few steps away from tracking our Google Analytics data in WordPress. As soon as you go to your WordPress dashboard, Click on Appearance in the left menu, and go to the Theme Editor.

Step 6: Locate header.php in the right side of the dashboard.

In the Theme Files menu displaying on the right side of the dashboard, Click on the Theme Header.

If your child theme is inheriting data from a parent theme you will not see header.php. In order to edit the parent theme click on “Select theme to edit:”, right above where it shows the theme files.

Now locate, <head> on the main screen and Paste the copied script from the previous step, and Click Update File.

Now Google Analytics has been added to your WordPress website. You will be able to see data in the Google Analytics dashboard usually after 48 hours.

Method 2: Add Google Analytics to WordPress with Google Tag Manager

Before we try to add Google Analytics to your WordPress website using Google Tag Manager. You have to make sure that you have signed up for Google Analytics, and have completed the above steps.

Step 1: Sign up for Google Tag Manager (Accept the service agreement)

Step 2: Copy the code to install Google Tag Manager on your website

Step 3: The first code needs to be pasted after the <head> tag and before the </head> tag. Ideally, you should be pasting it right after the <head> tag.

Step 4: Open the Google Tag Manager and hover to the main screen

Step 5: Click on Add a new tag. In the new window set a name for your tag such as your website name.

Step 6: Configure the Tag and Trigger in GTM for adding Google Analytics to a website.

Step 1: Sign up for Google Tag Manager (Accept the service agreement)

Select Web as your target platform and Click Create.

Step 2: Copy the code to install Google Tag Manager on your website

Step 3: The first code needs to be pasted after the <head> tag and before the </head> tag

Ideally, you should be pasting it right after the <head> tag.

Similarly copy the other code and paste it in the <body> tag of the WordPress dashboard. In the same window if you could scroll down you will see the <body> tag.

Once you have pasted both the codes in the WordPress Theme Editor, you can click the Update file button.

Bonus: You can install this Google Chrome Extension to see if the Tag manager is working properly.

Step 4: Open the Google Tag Manager and hover to the main screen

Step 5: Click on Add a new tag. In the new window set a name for your tag such as your website name.

Setting up tag helps in Tag Manager to let you create a trigger to fire whenever a page view is hit.

Step 6: Configure the Tag and Trigger in GTM Click

Now in the tag type, choose, “Google Analytics: Universal Analytics” as the tag type.

Now the tag type is selected as Google Analytics: Universal Analytics. You can leave Track Type as Pageview and change the Google Analytics Settings from the drop down to New variable.

Once you select New Variable, the new window will ask for the Tracking ID.

In order to find the tracking ID, go to the Google Analytics dashboard as shown in the above steps. Copy the tracking ID and paste it in the relevant field as shown in the screenshot above.

The next step is to scroll to Triggering and select to configure the trigger. In the new window, the tag will be preselected to “All pages”, leave it as it is, and just click on it.

And finally save the changes in the tag manager to enable Google Analytics in WordPress.

In the next window make sure to Submit the changes made for Google Analytics to work properly.

To ensure the tag that you have set for Google Analytics is working properly, Click Preview in the top right corner of the dashboard, and add your website URL in the Pop up and Click Start.

This will verify that the Tag you have set up for installing Google Analytics on your website is firing properly.

Now that you have set up Google Analytics in your WordPress website. You can easily populate all the data from Google Analytics to your WordPress dashboard.

How to Add Google Analytics in WordPress Dashboard

When you have a lot of websites to deal with, it becomes pretty hectic to manually track data in Google Analytics. To curb this situation Analytify comes in pretty handy in bringing all your website data into the WordPress dashboard.

Analytify offers both, a free and a paid version with advanced features.

In order to integrate Google Analytics in the WP dashboard, go to Plugins in your WordPress dashboard, and search for Analytify or Google Analytics. 

If it is easier for you then can you download the plugin and upload it in the WordPress directory manually.

Once you activate the plugin you will see a notification as shown below.

You now need to connect your Analytify with your Google Analytics Account. Well, either of the above methods you followed to add Google Analytics in WordPress, you can now simply connect Analytify with your Google Account.

Once you click connect, you will be taken to a new window. From there you can select your relevant Google account which you used to sign up for Google Analytics.

In the next window you will be asked if you want to allow Analytify to access your Google Analytics data, click Allow and you will be able to see your profile.

Make sure your selected Profile for posts (Backend/Front-end), and Profile for the dashboard is the same.

Once you have selected your profiles, Click Save Changes.

Now you can easily view your website data in the WordPress dashboard. Analytify brings limited statistics in the free version, as shown below.

You can upgrade to the pro version, by either from your WordPress dashboard or check out the pricing page.

FAQ

Does Google Analytics work with WordPress?

Yes, Google Analytics is compatible with WordPress. In fact, it works with almost any CMS such as Joomla, Drupal, or Magento.

By integrating it with a plugin in your blog or business website you can easily get the data in the WordPress dashboard.

Do I need to put Google Analytics code on every page?

No, you are not supposed to put Google Analytics code on every page of your website. All you need to do is place the code between the opening <head> and closing </head> tag of your website.

It is always advised to place it as soon as the head tag opens to ensure precise tracking of data.

Is Google Analytics a plugin?

Google Analytics is a free web and app analytics tool available to anyone. It is not offered as a WordPress plugin, however, you can easily install Google Analytics in WordPress using a plugin like Analytify.

Can you set up Google Analytics for multiple websites with the same Google account?

Yes, you can set up Google Analytics for multiple websites by going to the Google Analytics Admin section. There is an option to add a new account that would be your new site.

How to View Google Analytics Reports 

Since you have Google Analytics installed on your website, you will be now able to see tonnes of data related to your website. But you will not be able to see this data until 48 hours as it takes a couple of hours to populate the data.

Once you have all the data available in the Analytics dashboard you can visit https://www.analytics.google.com/  and you will be able to see the Analytics dashboard.

The Analytics dashboard is divided into the following 5 reports which are further divided into subcategories.

  1. Realtime: It has all the data related to your visitors which are currently on your website.
  1. Audience: Within this section of reports you will be able to see data like devices, demographics, geography, and much more.
  1. Acquisition: The Acquisition report is where you will get to know how your website drives traffic, such as organic, social, referral.
  1. Behavior: This side of the reporting will keep you informed on data like most popular pages, average time on page, exit pages, content drill down, and much more.
  1. Conversions: Within the conversion reporting of Google Analytics you can find all the data that matters to your business. It covers reporting on goal completion, eCommerce, and multi-channel funnels.

I hope this guide was helpful in setting up Google Analytics in WordPress. It is very helpful for marketers and business owners to track and monitor their website performance.

14 thoughts on “How To Add Google Analytics To A WordPress Website In 2021

  1. Hi! I just have a question, I entered the Google Analytics code in the header.php part but… wouldn’t that be erased when you update the theme?…

  2. Hello
    I have had so much trouble selecting Profile for posts, nothing shows up here, I cannot select nothing from it. In order to used google analytics I must give a code or call a code from this plugin. But it didn’t show me an option, What should I do?
    Thank you in advance
    Jennifer

  3. Hello
    When I click selected Profile for posts nothing shows up, it is already difficult. I don’t know what to do to get google analytics code inside the website. Thank you very much.

  4. Hey Tayyab, I am glad that I found your blog thanks for sharing this article. I was really searching for some information like this. Thanks for sharing this blog. I got all the information that I was looking for.

  5. Hello, Tayyab, great job on creating such an amazing and informative article! I think in my opinion, Adding the analytics using a plugin is the best way as you will never lose the code when you update the theme and they also offer you a wide range of options with rich additional features.

Leave a Reply

Your email address will not be published. Required fields are marked *