How to add Google Analytics to WordPress

Do you want to track your website’s traffic and want to add Google Analytics in your WordPress website?

You are at right place. I will show you how you can integrate Google Analytics in your WordPress website.

How to Add Google Analytics to WordPress

If you already own a complete WordPress blog or website then next step is to track and analytic your website’s traffic so that you can make the rest of changes on your website.

Normally every webmaster want to know about the visitors of their website. A webmaster want to know how visitors are behaving and interacts on his website. This can only be possible with the help of Google Analytics tool.



I hope you are already aware of this that WordPress are famous for the vast functionalities available in Admin panel. But checking website’s statistics can only be possible using Google Analytics tool.

So I am deciding on writing this guide for our customers so that they can integrate the Google analytics tool in their websites. By doing this they can check the statistics of their WordPress website without leaving the Admin panel.

But before proceeding you might think that what the benefits of using Google Analytics and why we should use it. So let me clear it first.

Why to use Google Analytics?



Generally everyone setup website with his individual goal. There must be a concept whether the website is a blog about a topic, an online store or a social website.

Whatever the goal is for creating website but you should be aware of your visitor. You should know from where visitors are redirecting to your website, and what content they are reading most on your website and how they are navigating on your website.

Using a free Gooogle Analytics tool who can gather information in background about your visitors which is most important to target the actual clients or visitors.

You can gather below data using Google Analytics:

Bounce Rate: It is a percentage of visitors who visit your website and leave your website without viewing any other page of your website. For example if 10% of your visitors will leave after viewing the landing page only then the Bounce rate will be 10%.

Session: Session word is already defining its meaning. Meaning for how much time visitors is active on your website.

Traffic Source: Traffic source means from where the traffic is redirecting on your website. Whether it is a direct traffic or redirecting it from Google search engine or from somewhere else.

PageView: It is a kind of metrics to define total number pages viewed by a visitor or loaded in a browser of your website.

Conversion Rate: You can calculate how many visitors are completing actions on your website.

What are the benefits of Using Google Analytics?



1) Easy to use: Due to its simple and refine structure and pattern it is easy to use for a beginner. A new user and easily understand the fundamental of Google Analytics and do it configuration by its own.

2) Understanding of Visitors: This tool will let you the know about the traffic of your website. You can easily understand how the traffic are behaving, their preferred pages of your website, etc.

3) Customize Reports: You can able to use drag and drop facilities available in this tool to create your own customize reports about your website’s statistics.

4) Report Sending: Receiving reports via emails after a fix interval of time or in periodically is possible.

5) Data Export: Exporting data in preferred format like excel can be done in Google Analytics.

6) Realtime Reporting: With this tool you can able to Get feedback while running campaign for your website’s traffic.

7) Monitor traffic device accordingly: You can easily monitor your website’s traffic accordingly to the device that is using. You can check whether mobile, tablet or PC traffic is converting on your website or not.

Now let’s start integrating Google analytics tool on your WordPress website:

How to add Google Analytics to WordPress?



In a WordPress website it is very easy to install Google Analytics tool with or without a plugin. When you have added this code then you will be able to monitor the activities of your visitors on your website.


Now I am explaining these above two steps in details which will make it easy for you to add Google Analytics to WordPress.

1) Get Google tracking Code


First of all you need to get your Google tracing code by following the below mentioned steps:

Step 1) First of all you need to sign in Google Analytics using your Gmail account.

If you don’t have account yet then you can click on Create Account showing in the login page.

Sign In Google Analytics

Step 2) If you are logging first time then you need to click on Signup showing in the right side as shown in the below screenshot.

Sign Up Google Analytics

Step 3) Now you will be redirected to a New Account page where you need to setup you account under Website property. You need to enter all the information as shown in the below screen-shots to set up and to add your website.

Set Up Account

Step 4) After entering the required information you need to scroll down and click on Get Tracking ID button.

Get Tracking ID

Step 5) Once done with click on Tracking ID button terms of service Agreement will be displaying on the screen. You need to accept the agreement.

Accept Aggrement Google Analytics

Step 6) On the left side menu, you need to navigate to Tracking Info > Tracing Code. This will show your Google tracking code as shown in the below screenshot.

You can copy that code and save it in your PC/Laptop as we will add this code in your WordPress website.

Google Tracking Code

2) Adding Google tracking code in WordPress website.


Normally there are 2 ways with which you can add the Google Tracking Code in your WordPress website.

1) Add it in footer.php file.

2) Add it in function.php file of activated theme.


Now I am describing these above two methods one by one. If you will facing difficulty then you can try to integrate using plugin method.

Method 1) footer.php method


Step 1) Login to your WordPress Admin panel. If you don't know how to login to WordPress Admin panel then you can read our guide on ho

Step 2) On the left side in the WordPress Admin Panel you need to navigate to Appearances > Editor from the left side of the page.

Navigate Editor WordPress Admin panel

Step 3) Now you will be redirected to a page where you will see theme’s files in the right side of page. You need to select footer.php file.

Edit footer.php file

Step 4) You can add your Google Tracking Code at right above the </body> tag in footer.php file as shown in the below screenshot.

Add tracking code in footer.php file

Step 5) At last you need to click on Upload File button to save the made changes.

Update footer.php file

Method 2) function.php method


Step 1) Login to your WordPress Admin panel. If you don't know how to login to WordPress Admin panel then you can read our guide on ho

Step 2) On the left side in the WordPress Admin Panel you need to navigate to Appearances > Editor from the left side of the page.

Navigate Editor WordPress Admin panel

Step 3) Now you will be redirected to a page where you will see theme’s files in the right side of page. You need to select functions.php file.

Edit functions.php file

Step 4) After selecting functions.php, you will notice it will open in editor. Now add the below code in the function.php file of your installed theme.

Note: Don’t forget to add your Google Tracking Code in the below code.

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


Step 5) After entering the above guide, scroll down and click on Update File to save the made changes.

Conclusion:


Congratulations! You have successfully entered the Google Tracking code and add Google Analytics in your WordPress website.

Now you need to visit your website in your browser. If you have correctly entered your Google tracking code then it will be verified automatically.

You can also add Google Analytics Dashboard in your WordPress website by taking help from our guide.

Thanks for reading this guide and don't forget to give your valuable feedback and review on our Facebook page.