Sunday, June 21, 2015

Best ways to add Google Analytics tracking code in WordPress?


Adding Google Analytics Tracking Code to WordPress is made easy


Adding Google Analytics tracking code to a WordPress is quite easy. It can be done in two or more ways, which is comfortable to you. Here we are going to tell you the best ways to add Google analytics tracking code to your WordPress blog or website. In order to add the tracking code, firstly we need to get the tracking for the respected website from Google analytics. Let us go to the detailed step by step process.


Google analytics tracking code to WordPress
Add tracking code to WordPress

How to get the Google analytics tracking code?


The first thing you need to create a new account in Google analytics. If you already have Gmail account, you can use that account in order to sign up for the process. You can sign up here Google Analytics Sign up. If you don’t have a Gmail account, you need to create one for you to sign up.


You will see the Access Google Analytics option on the top right side corner. A reference image 1 is provided below.


Reference Image 1
Reference Image 1

On the next step, you need to sign-in with your Gmail account. See below reference image 2


Reference image
Reference Image 2

Once you sign in with your Gmail credentials, on the next page you can see the below screen, this is where you will sign up for Google Analytics using your Gmail account. Click on the Sign Up button.


Reference Image for sign up process
Reference Image 3

On this page you will be asked to choose between a website and mobile app. You should select a website. In this you should fill your account details.


Sign Up with Google Analytics


Set up your Account Name: Pick a good name for your account

Setting up Property for WordPress Website:

These are settings to get the tracking code for your blog or website.

1. Website Name: Fill it with your website name, generally the title of your website would suit best here.

2. Website URL: Choose between http:// and https:// and write down your URL in the given box without http:// parameter.

3. In the next you will need to select the category of your website. Select the category that best suits you depending on your concept of your website.

4. Reporting time zone: Here select the exact reporting time of your country. That would be helpful for you to schedule your posts in the right time for your audience.

5. Click on the Get tracking code on the bottom of the page. And you will be prompted to accept the license agreement. You should accept it in order to get the tracking code for your website.

6. Now, you are presented with tracking code for your WordPress website.


How to add Google analytics tracking code to WordPress


After you successfully got the Google Analytics tracking code you need to place it into your WordPress website. Let us go into the details.

You can add Google analytics tracking code into your WordPress website in two more ways. But here we are writing the best three ways to add Google Analytics tracking code to WordPress website.


Using Plugins


This is a recommended method to add tracking code to your site without touching a line of code. There are so many plugins to add Google analytics tracking code to your site. We prefer to use Google Analytics Dashboard for WP, which is possibly the best with lighter weight. You can simply copy the Google Analytics tracking code and place it in plugins settings page.


Copy Paste Method in body section of Theme


In this method copy the piece of Google analytics tracking code and paste it in respective themes header.php after the body tag and save the file.


Copy Paste Method in Functions.php


Copy the following code in the theme’s functions.php file with your Google analytics tracking code. Don’t forget to add Google analytics tracking code to the following code.



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


Note: Replace the text (Paste your Google Analytics code here) with Google Anlytics Tracking code.

Once you have finished adding the code, save the file. Now you have successfully added your Google analytics tracking code to WordPress website.


Now you can get back to Google analytics page and select the respected property and view the analytics of your WordPress website. It may take 24 hours of time for Google to provide your site analytics on dashboard.



Note: Free WordPress blogs cannot use google analytics benefits. This article is only for self hosted blogs.

Google Analytics is one of the keys for the success of bloggers, so add your awesome website to Google analytics now and view your stats. If you have any queries regarding the topic, please feel free to ask in the comments section. Hope this article would help you in adding your website to Google analytics. Please share it with friend-bloggers on Facebook and Twitter.


 



Best ways to add Google Analytics tracking code in WordPress?

No comments:

Post a Comment