How to Install Google Analytics in WordPress (4 Methods)

GET PREMIUM WORDPRESS PLUGINS & THEMES AT 90% DISCOUNT

How to Install Google Analytics in WordPress

Disclosure: This content is reader-supported. If you click on our links, we may earn a commission.

Picture of Munish Siwatch
Munish Siwatch

Web Developer & Writer

Are you looking for various methods to install Google Analytics in WordPress website? Well, in this article we are covering Google Analytics installation on the WordPress website with and without plugins.

Google Analytics is most important for your WordPress website and is the best way to find out how your visitors are interacting with the website. It not only helps you to find out the number of visitors to your website but also allows you to sort out your results with various dimensions.

In our previous article, we have covered How to Set Up Author Tracking in WordPress with MonsterInsights in Google Analytics.

Author tracking is a dimension that can be configured to find the performance of each author on your website. You can easily create many other such dimensions to know the performance of your website.

But it is important to install and configure Google Analytics on your WordPress website the right way. We’ll show you how to install Google Analytics on your WordPress site in simple steps.

Before we proceed further it is important to know, why Google Analytics is important for your website and how it works. Further to this article, you will also find the right way to set up your Google Analytics account and then the installation procedure in WordPress.

Google Analytics for WordPress – The complete Guide

Most of the webmaster is still not clear with the purpose of Google Analytics on their website and how it can help them grow their website. Firstly, it is important to know what is Google Analytics.

What is Google Analytics?

Google Analytics is the comprehensive free web analytics tool for your website to track your visitors and find where they are coming from. It also allows you to find what your visitors are doing on your website, which is popular content and so on.

google analytics

Your website acts as the hub for digital presence over the internet. If you are running any advertising campaign or any other search campaign then Google Analytics gives you the holistic view of all the campaigns running to promote your product or website.

Aside from basic visitor engagement stats, some of the Google Analytics trackings features you’ll find useful are:

  • Ads tracking
  • Enhanced eCommerce tracking
  • Events tracking
  • Online forms tracking
  • Author tracking
  • And a lot more

That’s why over 50 million websites around the world use Google Analytics. If you are not using it, you should set it up right now.

How Does Google Analytics Work?

Once you set up a Google Analytics account (which is covered later in this article), you will be given a piece of code that you need to paste on your website. If the code is not properly pasted the way it should be then Google Analytics will not work properly for your website.

The tracking code must be added on every page on your website. This can be done by adding the code right into the header section of WordPress. The code records various activities of your users when they visit your website.

The code also records the visitor’s attributes (such as age, gender, interests) of those users. It then sends all that information to the GA (Google Analytics) server once the user exits your website.

Next, Google Analytics aggregates the data collected from your website in multiple ways, primarily by four levels:

  1. User-level (related to actions by each user)
  2. Session level (each individual visit)
  3. Pageview level (each individual page visited)
  4. Event level (button clicks, video views, etc)

Why Use Google Analytics in WordPress Website?

Understanding your visitors is the key to success for your website. It helps you to grow your website traffic, convert them to subscribers and increase your revenue. Google Analytics on your WordPress website helps you to gather all such visitor’s data to take your website to the next level. That way, you can eliminate guesswork and start making informed decisions based on the data you’ve gathered.

Before we proceed further let’s first check out the few benefits of tracking your website visitors using Google Analytics:

Know Your WordPress Visitors in Analytics

Google Analytics helps you to collect and track visitor information such as geographical location, demographics and interests, devices and browsers they used while viewing your site, and a lot more.

google analytics in WordPress dashboard

You can simply curate the contents addressing your visitor’s needs. If you find one of your articles is outperforming and most of the visitors are females from the US. Then you can opt-in of the interest of the visors so that you can easily convert them to subscribers and then customers.

This is just a small example wherein you can use your single article to get more leads.

Understand How Visitors Interact with Your WordPress Website

It is important to know what your visitors are exactly doing once they come to your website. You can track the visitors staying time on your website and then make your own strategies to convert them to leads and even convenience them to purchase products from your website.

google analytics report

For any strategies that you want to make on your website for your visitors, you need to have the complete data of your visitors. Here is where Google Analytics comes in to picture.

Understand From Where Your Website Visitors Arrive

Another important fact to know about your website visitors are from where they actually arrive on your website. Once you know which of the sources contributes maximum to your website you can build your strategies better.

google-analytics-wordpress-traffic-source

It can also give you insights into how to increase your website visitors.

Google Analytics provides you the break down of different traffic sources such as search engines, social media, referrals, direct traffic and more. You can analyze the maximum contributing source for your website.

For example, if your top referral source is an external website, then you might want to consider having a partnership with that website such as submitting guest posts.

Till now you must be very clear that Google Analytics is something that you need for your WordPress website and can’t be avoided.

Now let’s see the right procedure to create your Google Analytics account and then integrating it with your WordPress website in various ways (with & without plugins).

How to Set Up Google Analytics Account? (Right Way)

Setting up your Google Analytics account the correct way is very important. So let’s take a look at how to set up Google Analytics account for your website, step by step.

Step 1: Sign Up for a Google Analytics Account

Before you start installing and setting up google analytics for your website the first thing you need to do is sign up for a Google Analytics service. Google Analytics is absolutely free, so all you need to do is to visit Google Analytics and sign up with your Google account.

once you visit the Google Analytics page, on the right-hand corner you will find the Sign In drop-down button. Simply click on it.

how to sign up google analytics

On the drop-down menu, you will be prompted multiple options to select from. Since we are signing up for the Analytics account you need to click on Analytics.

click-on-analytics

Once you click you will be redirected to the page where you can simply sign in with your existing google email or Gmail credentials. If you are having Gmail account you can create a new account by simply click on the create account button and following the simple steps.

sign-into-analytics

Once you have signed into your Google account, you’ll need to sign up for Google Analytics. Click the Sign-Up button on the right side of the page to get started.

google-analytics-signup

Google Analytics gives you the flexibility to set up the account separately for websites and mobile apps. But in this case, we are focusing on setting up analytics for the WordPress website.

Make sure you select the website option at the top.

GA-track-website

Once the website selection is done you need to scroll down and enter your website information. You’ll also need to name your Google Analytics account, and enter your website name, URL, and industry, as well as your time zone.

Make sure that you fill in the correct details. In fact, choosing a different timezone will give you the analytics as per that timezone and not as per your geolocation.

ga-account-setup

Once the filling in your website details is completed, you can scroll down a bit to customize your data sharing settings. When you’ve finished selecting your options, you can click the Get Tracking ID button at the bottom of the page.

get-analytics-tracking-id

Once you click on Get Tracking ID, a popup window will be prompted with terms of service. You need to go through them and accept them.

accept-google-analytics-tos

That’s it! You’re now signed up for Google Analytics.

Once you have completed setting up the Google Analytics account you need to copy the tracking code which will come handy further in this tutorial.

Step 2: Find & Copy Google Tracking Code

This step is essential if you are manually configuring Google Analytics with your WordPress website. Further in this tutorial, we will be covering the manual configuration on Google Analytics with your wordPress website.

However, we recommend our users to use MonsterInsight WordPress plugin instead.

To find the tracking code you need to sign in to your Google Analytics account and go to your website which you have created earlier in this tutorial.

Under the second column in your website property, you will find the drop-down button tracking info. Simply click on that and you will get multiple drops down options.

google analytics tracking info

Under the dropdown option click on tracking code and you will be redirected on the next window where you will find the tracking code for your WordPress website.

google analytics tracking code

You need to copy and keep this code safe for manually configuring Google Analytics with WordPress website.

If you have successfully configured the code on your website you can click the send test traffic button and you will find a test visitor coming to your website.

Here we have completed with signing up of Google Analytics account and finding the tracking code for further use in this tutorial.

Now let’s continue with setting up Google Analytics on WordPress website.

How to Install Google Analytics in WordPress?

Now since you have already signed up for the Google Analytics account, the next thing you need to configure it with your WordPress website. There are many ways in which Google Analytics can be added to your website.

Let’s have a look at them below:

  1. Install Google Analytics using MonsterInsights (Recommended)
  2. Adding raw tracking code using Insert Header and Footer plugin
  3. Manually add the tracking code in header.php file of your theme
  4. Manually add the tracking code in functions.php

MonsterInsights vs. Manual Installation of Google Analytics

Before we go ahead with the step by step procedure of installing Google Analytics on WordPress website, I would like to take your attention towards the MonsteInsight plugin and why it is recommended over manual Analytics installation.

If you have good knowledge of WordPress then installing Analytics manually is not a big deal. You can simply add the tracking code to your website without using any plugins.

While manually installing Google Analytics allows you to gather basic traffic stats like sessions, page views, bounce rate, etc., the downside is that it doesn’t allow you to leverage the full potential of Google Analytics.

monsterinsights wordpress plugin

But if you are looking for the advanced traffic stats then Monsterinsight comes into play. MonsterInsights WordPress plugin makes use of more Analytics tracking features like download tracking, link tracking, forms tracking, eCommerce, tracking and more, you’ll have to manually customize the code for every instance.

Without a doubt, this can be tedious especially if you’re not a developer or an Analytics expert.

Any mistake while configuring the Google analytics on your WordPress website can lead to incorrect data from your Analytics account and will lead you to take wrong decisions for your business and website.

On the other hand, MonsterInsights is the most popular and trusted Google Analytics WordPress plugin, which makes it super easy to install Analytics with just a few clicks.

You don’t require to touch a single line of code with MonsterInsights. To enable enhanced tracking features, all you have to do is to make a few clicks or install the respective addons.

MonsterInsights Lite is the free version of the plugin offering the basic tracking features. But in case you need advanced tracking features, which is recommended for every website you need to go for the premium version.

They are offering a 50% special discount to all Bloggersutra readers. So what are you waiting for get started with MonsterInsights today?

Get 50% off on MonsterInsights Premium version

Now let’s dive in with various Google Analytics installation methods for your WordPress website.

Method #1: Install Google Analytics on WordPress Website Using MonsterInsights (Recommended)

Just out of the context, we have been using the Monsterinsight premium version on all our and our client’s website for quite some time. I can assure you the results are awesome.

To set up Google Analytics on your WordPress website we recommend you to subscribe any of MonsterInsights Pro plans as per your requirements and download the plugin.

Once you have downloaded the plugin you can follow our step by step guide on how to install a WordPress plugin.

But rather you want to give a try with the free plugin, head over to Plugins » Add New. Search for MonsterInsights and, when the plugin shows up, click Install Now and then, Activate.

install-monsterinsights

Head over to Insights » Settings to authenticate your blog with Google Analytics. Click Authenticate with your Google account that you have created in the previous steps.

click-authenticate-with-your-google-account

On the next screen, select your Google account.

choose-a-google-account-for-analytics

Next, allow MonsterInsights to manage your account.

allow-monsterinsights-to-manage-analytics

Finally, select the correct website profile for your blog and click Complete Authentication.

authenticate-monsterinsights

After authentication, you can easily find how your website is doing by visiting Insights » Reports.

wordpress-google-analytics-with-monsterinsights

Instead of going to the MonsterInsights reports every time you can configure it shows the analytics directly on the WordPress dashboard.

After the installation, you might not immediately start seeing information on your Google Analytics dashboard. It will take about 12 to 24 hours (or sometimes even 48 hours) before you can see any data in your Analytics account.

Note: The free version of the MonsterInsights only shows the basic tracking results. If you want the advanced tracking for your WordPress website you need to subscribe to the premium plans.

Get 50% off on MonsterInsights Premium version

You have witnessed that installing and configuring Google Analytics on WordPress website with MonsterInsights is pretty simple. However, if you are looking for the manual configuration follow the procedures given below.

Method #2: Add Google Analytics code using Insert Header and Footer plugin

Since you have decided to add the Google Analytics code manually to your website, here is another plugin that lets you configure Google Analytics without touching any code on your website.

However, the plugin lets you to simply integrate the Analytics and doesn’t provide any reports in your WordPress admin panel. To view and manage the reports you need to log in to your Google Analytics accounts.

First, you need to install and activate the Insert Headers and Footers plugin. For more details, see our step by step guide on how to install a WordPress plugin.

You can add the raw tracking code (which we have copied earlier in this tutorial) to your site’s header with the Insert Headers and Footers plugin. After installing and activating the plugin, go to Settings » Insert Headers and Footers and place the code into the plugin’s settings.

insert-headers-and-footers

It is recommended that you should place the code in the header section of the plugin. Once you have pasted the code simply save the setting and you’re done.

To check if the code is placed properly you can go to your Google Analytics account and send the test traffic to your website. The procedure we have mentioned above.

That’s all, you have successfully installed Google Analytics on your site.

Method #3: Insert Google analytics in header.php of WordPress Theme

Following this step, you should be extra cautious. You need to have a little knowledge of coding. Any small error can cause a malfunction of your website.

It is recommended that you should always take a backup before you proceed with this and the next step. To make it easy you can find the list of best WordPress backup plugins (Free and Premium).

Go to Appearance » Editor and find and click on the header.php file on the right side of the window.

add-to-header-file

A slightly more complex way would be to open your theme’s header.php and place the code right after the <body> tag.

tracking-code-added

Please note that if you add the code to your main theme, then it will be overwritten whenever you update your theme. Using a child theme is the best way to add customizations like this to your WordPress site.

Method #4: Insert Google analytics in function.php of WordPress Theme

This is another method that is almost similar to the previous method and is slightly more complex.

If you feel confident in your knowledge of PHP you can open your theme’s functions.php and add the following code. Make sure you replace the fourth line with your Google Analytics code.

<?php
add_action('wp_footer', 'add_googleanalytics');
function add_googleanalytics() { ?>
// Paste your Google Analytics code here
<?php } 
?>

Using any of those methods you should have added Google Analytics to your site.

How to View Reports in Google Analytics?

Google Analytics is capable of showing you all the data that it had collected from your website. But if you want to see the advanced Google Analytics directly on to your WordPress dashboard then you must install MonsterInsights plugin.

You can view this data by visiting your Google Analytics dashboard.

gareporting

You will see the built-in Google Analytics reports in the left column. Each section is divided into different tabs and clicking on a tab will expand it to show more options.

  • Real-time This report will show you a real time view of your traffic.
  • Audience tab will show reports to help you understand your users.
  • Acquisition reports explore where your users came from.
  • Behavior reports summarize what your users do after they arrive on your site.
  • Conversion reports show how well you’re doing against your goals.

Google Analytics is an incredibly powerful tool with tons of awesome features. Some of them are quite obvious and easy to use, others require some additional setup.

Final Thoughts About Installing Google Analytics in WordPress

In this tutorial, we have covered all the best possible ways to install Google Analytics on your WordPress website.

Google Analytics works best with Google Search Console (formerly Google Webmaster Tools). It allows you to see how your website is doing in search results. See our complete Google Search Console guide to learn how to use it to grow your website.

If you want to make Google Analytics work best for your website to generate advanced reports to take your business to the next level then you require MonsteInsights plugin.

Get 50% off on MonsterInsights Premium version

With over 2 million active installs, MonsterInsights is the most popular and comprehensive Google Analytics plugin for WordPress. Not only does it make Analytics setup easy, but it also lets you enable a lot of Analytics tracking features such as eCommerce tracking, downloads tracking, etc. without touching a single line of code.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

New to creating a website? Join our newsletter.​

Let us do the work for you. Receive a bite-sized dose of AI, Tech, and Business news
delivered straight to your inbox.

Join over 38,500+ satisfied readers and subscribe to ByteBrief today!

Power Your Business

Some of the tools and services to help your business grow.

Software that's powerful, not overpowering. Seamlessly connect your data, teams, and customers on one CRM platform.

Try Hubspot

SentryPC combines award-winning computer monitoring features with essential content filtering, time management & access control.

Try SentryPC

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
0 Shares
Tweet
Pin
Share
Share
Share