How to Add Google Analytics to WordPress (With or Without Plugin)

Knowing about how to add google analytics to WordPress should be the top priority for any website administrator. It’s the first step to know about the readers of your website and what they are looking for. 

how to add analytics to wordpress

In this tutorial I will discuss the following things about Google Analytics, Including:

What is Google Analytics?

Google Analytics is a web analytics service provided by Google for free to check the insights of users and visitors of your website. It tracks and reports your website traffic in a detailed manner all the time. Google introduced this in November 2005 after acquiring web statistics and analysis program Urchin that was developed by Urchin Software Corporation.

Why Do You Need to Use Google Analytics In Your Website?

Knowing about your customers is the foremost important thing for any business, either it is offline or online. This will improve your sales and also gives better understanding of your customers or visitors of the website.

Here Google Analytics does the same thing for you by providing all the information about your website visitors including.

  • Analytics Intelligence to get fast answers to questions about analytics data and insights.
  • Analyze and understand how users are interacting with your site using a wide range of reporting tools like audience reports, behavior reports, conversion reports, real-time tracking etc.
  • Access your data anywhere along with web applications, you can also access it through mobile app both in Android and iOS.
  • Integrate Google Analytics with various google products which includes Google Ads, Google search console, Google Adsense for better understanding your website visitors.

How to Signup with Google Analytics?

Google Analytics is a free tool to track your website visitors, to get started with Google Analytics you need a Google or gmail account.

Step 1: Go through this Google Analytics page to sign up. You need to login with your google account.  If you don’t have a Google or Gmail account then create an account first.

Login into Google Account

Step 2: After logging in with Google account you’ve to enter an account by giving account name. Type your desired account name and if you want to share your analytics data with google tick the below options or you can uncheck those boxes if you don’t want to share any data.

create account in google analytics

Step 3: After clicking the next button you need to choose the product you want to measure. Select web to measure your wordpress website.

choose type of account

Step 4: In the next step type your website name, address, industry category and reporting time zone then click on the create button.

choose category of website

Now you’ll be presented with Google analytics terms and services agreement which you must agree to complete the setup process.

Now you’ll get the tracking code of your website along with tracking id. Copy the tracking code and keep it aside to use it in the WordPress website integration.

tracking code of website

How to Install Google Analytics with a Plugin?

There are many plugins like monster insights, google sitekit, and GA google analytics available to set up google analytics on your website. Here I’m using Googel sitekit plugin which comes along with search console, pagespeed insights and Google adsense.

Now install the Google site kit plugin and activate it to set up in your wordpress dashboard. To activate the site kit plugin you’ve to go through a few verification steps which confirms you as an owner of the website.

google site kit

After completing all steps with integrating your google account to the site kit you’ll be able to see the data from search console, google analytics and pagespeed insights at one place. You can analyze data separately from the left sidebar by clicking site kit menu.

google site kit dashboard

If you don’t want other data like pagespeed insights and search console then use GA analytics plugin which only shows analytics data.

How to Install Google Analytics in Theme Without a Plugin?

If you prefer not to use a plugin for google analytics integration on your wordpress website then you can directly place google analytics code in the theme itself. For this method you need a child theme to avoid analytics code loss during theme updation.

Nowadays most of the themes provide child themes , if your theme doesn’t have a child theme then create yourself by following the below guide.

After installing and activating the child theme you need to paste the tracking code just before the closing </head> tag in your child theme header.php file. In this way you don’t lose tracking code whenever you update the main theme.

To add tracking code click on appearance > Theme editor then choose header.php and paste your site analytics tracking code just before closing </head> tag then click on update button to save the changes.

add analytics code before head

How to Install Google Analytics in theme with a Plugin?

If you find it difficult to add tracking code in header.php file then you can easily do this step by using a plugin called insert headers and footers plugin.

After installing and activating plugin go to settings >> insert headers and footers and paste the tracking code under scripts in the header section. Click on the save button will add that code directly into the header.php file.

add tracking code in headers and footers plugin

Now we are done with the analytics setup and tracking process. To check whether it is working or not go to google analytics dashboard by logging to your google account and click on admin in the sidebar. 

Also Read How to Install a WordPress Theme

Under property select tracking info then click on tracking code. Here you’ll be able to see traffic status. Click on send test traffic and you’ll observe that 1 active user right now under status.

Most of the time tracking code works within minutes of time.If it doesn’t show traffic even after clicking the send test traffic button then try after a few hours.

That’s it you successfully installed google analytics tracking code on your wordpress website. You can go with any one of the methods mentioned above as per your requirements.

If you find it difficult at any stage of implementation, feel free to contact me through contact form.

Leave a Comment