How to Add Google Analytics to WordPress
What is Google Analytics
If you are running a website then there are many questions which always come in your mind. Like from which place (Geographical) people are visiting your website, how long they stay on your site, The page for which they mostly visit your site, devices used by them to access your site, what medium they use to enter your site, are they enter by social media or directly from Google search engines or from any other website links or by entering your site address directly. You can also find the exact time of your website visitors when they are coming to your site.
You can easily get the answers for all these questions by using Google Analytics code to your website. It is only a JavaScript code which is used on your website page to track the visitors and what activities they do on your site. It collects all the activities of visitors and display in the form of statistics in your Google Analytics account.
You can easily add the Google Analytics code to your WordPress websites. There are two ways to add this code to your website. By using a plugin or without using a plugin
How to Add Google Analytics to WordPress Without Using a Plugin
When you have to add any new functionality in your WordPress sites, You always try to find some plugins. Because it will make your task easy and reduce your time period as well. But many times some badly coded plugins may harm your website. It will slow down your site. But if you use a well coded and light weight plugin it will save your time and complete the task in a very effective way. Firstly, you should always try to resolve your task first without using the plugin. Follow the Steps to add Google Analytics code to your WordPress site.
Before starting these steps take the backup of your full website because you are going to edit the core file. In case you do any mistake you will get your site back.
Step 1 : Obtain Your Google Analytics Code
Login to your Google Analytics account and get the tracking code for your website.
Go To Admin — Tracking Info — Tracking Code
Step 2 : Add Google Analytics Code to header.php file of Your Site
Log into your WordPress site and go to Appearance — Editor. And you will find theme file header.php there. Click on header.php
Add the piece of Google Analytics code after the body tag here.
Click on the update file button after adding the code. You have successfully added Google Analytics code into your WordPress site without using any plugin