How to add google Analytics to WordPress for Newbies

Posted by on

Share this


In this tutorial you will learn how to add google Analytics to WordPress ( Only for Self-hosted WordPress Websites ).

If you have a website, it is obvious that you want to know about your visitors and where they came from ? The best way to track them is through Statistics and this is what Google Analytics actually does. It helps you to track your visitors and their other activities.

Importance of Analytics :

Analytics is must for every blogger and website owner, It allows you track :

Visitor’s location and device they use

You can get the geographical location of your visitors and which browser they used to visit your site. Analytics will also tell you about the device (Desktop or Mobile) your visitors use to reach you which helps you to know about your desktop and mobile traffic.

Visitor’s Activity

You can track What your visitors do when they visit your website and the time they stay on your website.

How they came to know about your site

This is very important to know how your visitors came to know about your site or page. They came from Search Engine, from any social networking sites ( Facebook, Twitter and more ), direct links or from any other site.

Every blogger wants to know about their Audience and for this Google Analytics seems a right option. Everything that you want to know about your visitors you could know, once you start using Google Analytics account.

Some of the main Features :

  • Collection & Configuration APIs : It helps you to collect data and manage your account in custom. Let you know how users interact with your content and more..
  • Event tracking.
  • User Permissions.
  • Data Import : Import All your data in one place.
  • Product Integrations. 
  • Reporting : Audience Reporting , Benchmarking Reports, Custom Reporting, Performance Reporting, Ecommerce Reporting, Conversion Reporting and more..
  • Alerts & Intelligence : If any significant statistical variations, then you get alerts.
  • And many more ….

Before you do anything, The very first and essential step is to Create Google Analytics Account.

How to Signup with Google Analytics

Step – 1 :

To do this, Click on the Sign Up button to create a new account.

Sign Up

If you already have a gmail account then you can simply use that to Sign In. And if you do not have one then you will have to create a new account to get started. Add Google Analytics to WordPress – Easy guide for beginners.

add google Analytics to WordPress

Step – 2 :

Now you will see Sign Up page, Where you will see a new Sign Up button on which you have to click.

add google Analytics to WordPress

Step – 3 :

After clicking on the Sign Up button, You will see a new page where you will be asked to choose between Website and Mobile App.

You will choose Website, by default Website is selected but make sure once that the Website is actually selected.

add google Analytics to WordPress

Now fill the required details properly.

Step – 4 :

After filling the information, scroll down and click on the blue button – Get tracking code. Now read the terms and conditions and then click on the I Agree button.

add google Analytics to WordPress

Step – 5 :

Here you will get your tracking code. Now Copy the tracking code and visit to your site and paste the code. ( Where ? Scroll down and see the methods.)

add google Analytics to WordPress

How to insert the tracking code in WordPress to get started with Google Analytics

There are Three different ways to insert the tracking code in WordPress. Let’s see What are different methods to to install Google Analytics :
1. Direct Method or header.php Method 
You can paste the tracking code in your theme’s header.php immediately after the opening of <body> tag.
2. Plugin Method ( Recommended )You can install header and footer plugin and can paste the tracking code in header or footer section. I will always recommend this method to the beginners because it is very easy and a very safe Method.There are 100’s of free plugins available to add Google Analytics to your WordPress site. You should choose one with the light weight and which is easy to use. Add Google Analytics to WordPress.
Recommended Plugins :

3. PHP Implementation

I won’t recommend this method to the beginners. This method isn’t safe and if you really know about this method and you are friendly with the functions.php file then only use this method.

( Source : Google )

  • Use the code above to create a file named “analyticstracking.php”, and include the file on each PHP template page.
  • Add the following line to each template page immediately after the opening <body> tag:

Some themes do have a Separate option for Google Analytics tracking code. Better check your theme option and make sure whether you have any such option in your theme for Analytics tracking code or not ?  If it’s there then go with that and if not then you can use any above method.

How to Find your tracking code, tracking ID, and property number from existing Analytics Account.

If you have an analytic account and you want to find tracking code, tracking ID, or property number then follow the steps given below :

  • Sign in to your Google Analytics account
  • Click on the Admin tab.
  • Select your Property and select your Account too from the dropdown in the Property and Account section.
  • Now under the property, click on the Tracking info.
  • To tracking code click Tracking Info > Tracking Code.

Screenshot (171)

If you are not using Google Analytics yet, This might be the right time when you start using Google Analytics to track your site’s traffic. Add Google Analytics to WordPress.

Liked this Article ? If Yes then please do not forget to share it with your friends on Facebook or Twitter. If you have any question then you know that we are here for you, ask you are questions in the comments.

Add Google Analytics to WordPress Full Video

Last updated: May 29, 2016

Authored by :

Satyansh Tiwari is the co-founder of 3nions and currently an Electrical Engineering Student. He is a blogger, writer, graphic designer and SEO enthusiast. When he is free, he loves experiencing nature and traveling.

Leave a Reply