WordPress Tutorials

How to Install Google Analytics on WordPress?

Keeping track of your website is crucial if you want to improve your website’s visibility on the search engine and generate more leads from it.

Google Analytics is a free tool which helps you to analyze the behavior of your WordPress Blog. The tool gives you accurate stats about your website’s page views, user engagement, bounce rate, analytics of posts and much more.

Google Analytics for WordPress

While running a blog or a website, you should keep track of all such important details which would help you to optimize your website for the user.

Most of the newbies focus only on keeping track of the number of page views on their website, although they miss the central part- does the user even stay on the website or not?

1 Installing Google Analytics on WordPress

We have divided the whole installation process into two different parts. In the first part, we will see how to generate the Google Analytics code for your website.

In the second part, we will be primarily focussing on implementing the analytics code on your WordPress website.

2 Part 1: Generating the Google Analytics Code

2.1 Step 1: Sign In Using Your Google Account

Google Analytics sign in

To use Google Analytics, you should have a Google Account.

Click Here to Sign-In to Google Analytics

Sign in using your Google Account or create one if you don’t have it. It would hardly take 5 minutes.

2.2 Step 2: Sign Up to create a Google Analytics Account

Sign up for google analytics

After Signing In using your Google Account, you will get a screen like above. Click on Sign Up. Accept the Agreement and you will be successfully signed in to your Google Analytics account.

2.3 Step 3: Enter Your Website Details

Enter the website details

step-4-google-analytics

After accepting the terms and conditions, you will be redirected to a new page where you will need to fill in the appropriate details about your website. Select among Website and Mobile App. In this tutorial, we are installing the analytics code for a website.

  1. Account Name: This can be anything. If you are working for an organization, then enter the name of the organization. If you are working solo, you can give in any suitable name. With an account name, you can keep the visibility of the account singular, or you may even share the account with your team or department if you are working for an organization. You can read more on the Google Support regarding this.
  2. Website Name: Enter the name of the website for which you want to track the details.
  3. Website URL: Enter the complete website URL. Eg: http://www.WebsiteName.com. You can also click on the checkboxes if you want to share your site statistics with Google.
  4. Generate Tracking ID: After filling in the details, just go through it once again. Click on “Get Tracking ID” to get the Analytics code.

2.4 Step 4: Get Google Analytics Code

Google Analytics Code

After successfully filling up all the necessary details in Step 3, it will generate a Tracking ID along with the Analytics code. This Analytics code is needed to be applied on your WordPress website.

You can implement the Google Analytics code on your WordPress website in three different ways:

3 Method 1: Using Headers and Footers Plugin

If you haven’t added any custom code to your WordPress website before, don’t worry. Implementing a code on a WordPress website is easy. All you need to do is follow these four steps.

  1. Add a new Plugin
  2. Install and Activate Headers and Footer Plugin
  3. Configure the Plugin Settings
  4. Add the Necessary Code

3.1 Step 1: Add a New Plugin

Add a new plugin

  1. In your WordPress dashboard, hover to Plugins -> Click on “Add New.”

Note: You need the WordPress admin login credentials to install the plugin and activate the analytics code.

3.2 Step 2: Install and Activate the Plugin

Search Insert into headers and footers

  1. Search “Insert Headers and Footers” in the search box and press ENTER.
  2. Install the plugin by WPBeginner and Activate it.

3.3 Step 3: Configuring the Plugin

Insert headers and footers settings

  1. Hover to Settings -> Click on “Insert Headers and Footers” to change its setting.

3.4 Step 4: Implement the Analytics Code

Paste Google Analytics code

  1. After clicking on “Insert Headers and Footers,” you will be directed to the plugin settings. Here you can paste the code that was generated during Step 4. Paste the Google Analytics code in “Scripts in Footer.” This is because you need to implement the analytics code on each page of your website so that it can track the details correctly. While pasting the code, ensure to select and paste everything between and including the <script> and </script> tag.
  2. Save the settings.

You have now successfully added the Google Analytics code on your website. It might take some time to show your accurate details on the Google Analytics Page.

Now, let us look at the second method.

4 Method 2: Using header.php file (Not Recommended for Beginners)

You can also paste the Google Analytics code manually on your website. However, we would not recommend this method to beginners and newbies.

We would recommend you to take the backup of your website before implementing this method. Use our free backup plugin to be on a safer side if something goes wrong while editing the code.

4.1 Step 1: Go to Theme Editor

Find Headers.php file

  1. Hover to Appearance -> Click on “Editor” to access your Theme Codebase.

4.2 Step 2: Find header.php file

Find headers.php file

  1. From the left dropdown menu, choose your Theme to access its code. In above, we are using the ultrafast SociallyViral Theme.
  2. After selecting your theme, find the header.php file and click on it.

4.3 Step 3: Pasting the Google Analytics code

Google Analytics code in header.php file

  1. In your header.php file, paste the Google Analytics code including the script tag just before the </head> tag. In the above, use the tracking id that was generated in Step 4 instead of ‘UA-XXXXXXXX-XX.’  
  2. Click on “Update File” to save the changes.

You have successfully linked your WordPress website with your Google Analytics account. You may have to wait a while to get the exact metrics of your website on Google Analytics.

NOTE: You will need to implement this method again if you change the WordPress theme of your website in future. 

Let’s move on to the last and the easiest method to implement the Google Analytics Code.

5 Method 3: Use Themes from MyThemeShop (Recommended)

MyThemeShop provides you the advantage to apply the Google Analytics Code on your WordPress powered website without any hassle.

5.1 Step 1: Go to Theme Options

Theme Options

  1. Hover to Appearance -> Click on “Theme Options.” Theme options is an exclusive option provided in all the premium WordPress Themes provided by MyThemeShop so that you can customize the theme and add functionalities to your website with ease.

5.2 Step 2: Insert Google Analytics Code in Footer

Paste Google Analytics code in Footer

  1. After clicking on the Theme Options, you will be directed to General Settings. Scroll down to find the Footer Code. Paste the Google Analytics Code that you had generated earlier in Step 4. Include the <script> and </script> tag and the code between them. 
  2. Save the changes.

Congratulations! You have successfully implemented Google Analytics on your WordPress website. You might have to wait for a few hours to get the relevant details about your website on the Google Analytics page.

Wasn’t it so easy to implement the code inside a MyThemeShop Theme?

Apart from this, all MyThemeShop Themes support easy customization so that you have full freedom to change and modify your website according to your need. Due to these features and outstanding customer support, the result is – more than 650,000 Happy Customers.

Check Out our Ultrafast Fully Customizable Themes – CLICK HERE

Use Google Analytics to monitor the performance of your website. The tool can be utilized by anyone to improve their site visibility, gain more viewers, check new functionality, improve the bounce rate and much more.

So, that was all from our side to make you implement the free Google Analytics tool on your WordPress website.

Were you using any Analytics tool till now? What according to you is the easiest way to implement Google Analytics on a WordPress Website? Do share your views in the comment section below.

Download
Download 3 WordPress themes & plugins​ with lifetime access for FREE!
x