This article guides you on how to add Google Analytics to your WordPress in two different ways.
Why add Google Analytics to WordPress?
Google Analytics provides you with very detailed statistics about your website and the traffic coming to it. But, to use Google Analytics with a WordPress or any other site, first, you need to sign-up for a Google Analytics account at http://www.google.com/analytics and get a unique Tracking ID.
Once you set up the Google Analytics account and get the Tracking ID for your site, you can easily configure WordPress to it. You can do this, in two ways :
(i) By using a WordPress plugin.
(ii) By editing the WordPress theme.
Method 1: Adding Google Analytics to WordPress using plugin :
There are various plugins available that enable you to configure Google Analytics for a WordPress site, and they all function in one and the same ways. You just need to specify your Tracking ID, and the plugin will work as required.
Some of the popular Google Analytics plugins for WordPress are :
Method 2: Adding Google Analytics to WordPress by editing the theme :
Plugins seem to be convenient, but they carry processing overhead with them that may affect the site performance. If you don’t use a plugin then you can edit the WordPress theme directly to enable Google Analytics.
# Perform the following steps to enable Google Analytics by editing the theme :
1. Log in to your Google Analytics account.
2. Click on Admin, again click on Tracking Info, and then click on Tracking Code. Now copy the entire text in the tracking code box, including the starting <script> tag and the ending </script> tag.
3. Now, login to WordPress as an administrator.
4. Under the Dashboard, click on Appearance, and then on Editor. The Edit Themes page gets appear.
5. Go to Templates and under it click Header (header.php).
6. Identify the ending </head> tag. Just above this </head> tag, paste the Tracking ID code snippet from Google Analytics that you have got from Step 1.
Ensure that you include the starting <script> tag and the ending </script> tag.
7. Click on the Update File. Google Analytics will now be enabled for all pages on your WordPress site.
It may take up to 24 hours for Google Analytics to change its status from Tracking Not Installed to Receiving Data.
Also Read :