Web designer, SEO specialist, Content writer

Add Google Analytics to WordPress via analyticstracking.php

Voila, you have created a new website and now you want different ways to find information about who visits your website. What are reading interests of visitors and on which information your visitors are mostly interested upon and you want to know about it and have deeper invigilation so that ultimately you could write some article of interest on this same subject. Google Analytics is free and it provides sufficient information and measurement of site’s metrics to know about behavior of user’s interests and this could lead to building future interests upon which you could build sufficient information development.

Why Google Analytics:

Google Analytics provides real time reporting of website and real time statistics, their behavior, the web browsers they use, the operating system, and from which city they dwell in and from where they used to and which article segment they are planning to get into and all these information provides sufficient ground for development of real time analytics of visitors. For this you need to set up analytics tracking code for your website, and it is really easy to set up as there are many different ways you could install and activate Google Analytics on your site.

Google Analytics is from Google’s world class platform where every product of Google comes with bright cut free to use and provides additional information to web masters to sustain and perform at ease without any further need for installing any other third party costly analytics mechanisms. In this article, I would be solely talking about world class content management software such as WordPress and the most convenient and easy to use way to optimize and augment Google Analytics on website so that it would not provide any additional burden on web site so as to present user the same set of speedier site as usual.

Read on for lightest Google Analytics installation:

Most of web masters complain of the very nature of heavier page due to advent of Google Analytics on site as there are floods of article which suggest to discard this as it could result is slow down of website, but as per my advice and experience of over 10 years of web master I could suggest to install you and the most appropriate mediums is discussed here and this trick is from Google but still not been available in most of other reference sites. There are many plugins but I am not a supporter of using so much of plugins and I never ever prefer to use it as I only use two plugin such as akismet and one plugin which could generate XML sitemap for website. So, I go the way to install a script that would not make any weightless to website as many web masters feel of it.

Website analytics is a popular medium and many web masters prefer to user it on their content management system as most of such content management system such as WordPress, Drupal, Wiki and Blogger do provide different ways to amend and edit files so that these tracking codes could be installed automatically. In this article, we would be talking about how install Google Analytics tracking code on WordPress. I suppose you have created child theme so that anything goes wrong can be easily retrieved without going into additional changing of theme. I suppose you have to host and have access to Cpanel hosting so that you could reach to themes through file manager and root installation directory of WordPress.

How to add Google Analytics to WordPress via analyticstracking.php

Sign into your Analytics account. If you have a Google Analytics account earlier than you could use it or else if you do not have them open new account and preferably in the same email address with which you are using Adsense or Google+ with WordPress. It is not mandatory but it is wiser to be done. Most of webmaster prefer to utilize the same Gmail which they have been using Google Webmaster for their WordPress website.

Now, after doing essential sign into procedure, you could be reaching into Google Analytics dashboard.

Google Analytics Dashboard

I suppose you have created Google Analytics tracking code for website, and you would be presented with the name of website and click on it and then you would be reaching into sub-dashboard where you would be presented with four headings namely ‘Home’, ‘Reporting’, ‘Customization’, ‘Admin’ besides name of yours website. Refer above screen shot for details.

Click on ‘Admin’ menu to enter into its contents. (Screen shot Admin menu) Here, you would be presented with two sub menus such as ‘Account’ and ‘Property’. First menu provides details information about website, which would be necessary when we would be using these after installation of Google Analytics code on website.

Admin menu of Google Analytics

Now, return to second menu which is ‘Property’ where one could find refer to screen shot different sub items such as ‘Property Settings’, ‘User Management’, ‘Tracking Info’ and for the time being ‘Tracking Info’ is important for us. Click on ‘Tracking Info’ to enter into its sub segment.

In this segment we would be concentrating on ‘Tracking Code’ which is very important for us in this segment to collect tracking Code of website. While writing this article I would suppose the reader knows about how to create Google Analytics profile for website such as WordPress.

Now, click on ‘Tracking Code’ and after reaching there you would presented with unique Google Analytics id starting with UA-********-* This is the universal analytics code which could be used for tracking of website through property and mostly it is been used in content management sites of Blogspot Blogger system. Then, on the below of it, you would e presented with a tracking code with a box embedded within it and it is a java script code which you could be using it by putting it on the headr.php or footer.php of WordPress but here we are not talking about that way to install the Google Analytics script on your website.

Tracking Code

Copy that tracking code and keep it in a safer place as it would be necessary in order to create analyticstracking.php within the theme directory of Cpanel hosting. Log into Cpanel hosting and reach to Cpanel and from there click on ‘File Explorer’ to reach to root directory of WordPress.

Theme

Root directory of WordPress is the place where the entire installation of WordPress is done. Now reach to Wp content and click on it to reach the theme of WordPress. From there, you would be finding out different theme which you have installed earlier and choose the exact theme which is currently activated there.

How to create Googleanalyticstracking.php on the front end of WordPress inside currently activated file explorer of theme:

I suppose you have created a child theme of an existing theme and choose that theme to enter into its file directory.

Child theme

From inside file directory of child theme creates a new file and rename it as analyticstracking.php and paste the javascript codes which you copied from ‘Tracking code’ into it and save it within the file directory of the child theme.

Googleanalyticstracking.php

Install

<?php include_once (“analyticstracking.php”) ?>

on header.php just under opening body tag. Save it and you are done. Now, open header.php of child theme, if it is not there then copy that files from original theme to child theme and open it in file editor within Cpanel hosting. Then, we have to find out ‘opening <body> tag’ within header.php. The difference between PHP and XHTML codes is that you would not find any thing similar to ‘<body>’ tag within within frame works of header.php.

In fact, you should search for

<body <?php body_class(); ?>>

which is in fact opening body tag within header.php. Then paste

Opening body tag within header.php

<?php include_once (“analyticstracking.php”) ?>

Google Analytics PHP implementation

without block quotes just after above said opening body tag and save header.php.

Conclusion:

Now, you are done, now yours sites have Google Analytics installed and it installed through PHP implementation which is not at all heavier as it would only show only when website demands and header only command analyticstracking.php once so it would not slow in loading of web pages. I hope this tutorial would be immense help for you and help you in devolving in creating one of the smarter installation of Google Analytics tracking code into your website.

Google Analytics provides comprehensive information about audience data analysis, web browser and operating system they use mobile traffic, social traffic with cross device and cross platform measurement while providing comprehensive integration of social reports, application profiles, application metrics, dimension, crash reporting, returning visitors, Google Play integrations, AdWords, Adsense, Google Tag Manager integration to provide further analytics presentation of yours website. All this you have to install its code on your website and the above description should provide the most easiest and convenient way to install analytics script on your website.