Place Google Analytics Code

Google Analytics is one of the most accurate website analyzer of the website. It is offered by Google for free with unlimited features to track your website traffic. It is done through Google Analytics Tracking Code which is placed inside every page of the website. As users come on this page the analytic script checks the user behavior. Now there are custom dashboards with multiple website listings that can be managed easily with many google analytics features that are offered free of cost. One of the main questions that comes is where to place Google Analytics code? Should Google Analytics be in the header or footer or body?

In this post we are going to study all the required information that will help you guide understand about placing Google Analytics Code in a more systematic way.

Where to put Google Analytics Code?

Google official recommendation clearly says for efficient results in number of page views the best place to put google analytic code is before the <head> tag. Whether you have static or dynamic header is the most suggested way for proficient results. For static websites the simple code is to be put on every page whereas if you have dynamic site one code can be placed in dynamic header file from which all the analytics is fetched accordingly.

New Google Asynchronous has been proven to get more accurate results regarding page events by margin of 10-20% while with adwords it is 100% accurate for achieving higher performance.

Understanding Google Analytics Tracking Code

Google Analytics Tracking Code is a small JavaScript Code that is added to the website pages to track the visitor presence. This new JavaScript Asynchronous code is quite better than the old ones, loads instantly without any delays as well as once downloaded it can be used again and again by Google from cache only so further not affecting page load performance.

Old Google Analytics JS code used to load line by line affecting page load and performance so it wall recommended to be place at the end of the body tag or in the footer but new Analytics Asynchronous code is better in all prospects for higher performance.

Now Google Analytics is more powerful than ever with their connectivity with Search Console (Webmaster). With this functionality the whole search pattern can be accessed. Every URL, keywords with their impressions are noted which is quite a lot helpful for enhancing SEO performance accordingly.

Although there are few exceptions but it has been proven that header is the best place for analytics. The old version of the Google analytics code was proposed to be placed before </body> tag which has some issues related to page load performance but new asynchronous tracking code is more sensitive and correct with placement in <header> tag, once it starts the code runs parallel with page performance.

There are two ways of using Google Analytics Code

  • Standard Setup : Placing default code in Header is recommended
  • Custom Tracking Code Script : Just before the closing </body> tag for executing it as last element of DOM used for advanced purpose i.e. E-Commerce, Multiple domains, 3rd Party Shopping carts and custom variables

Google Analytics Tracking Code for Website

For HTML/Static websites
If your website is build using HTML only than place your Google analytics before <head> tag ends.

Google Analytics code header or footer

All the HTML pages must have this important analytics code so that every page can be tracked via Analytics data carefully.

For Dynamic Websites
When websites are built dynamically header file is chosen as the best practice, where you can easily put the Google analytics Tracking code. CMS also have the same patterns where one header is dynamically being called on all pages, so putting the code in the header.php does the trick like in WordPress. Although there are lot of plugins that can be configured for Google Analytics as well. Here we are going to know on adding this code directly in the Theme files.

Google analytics tracking code WordPress without plugin

For WordPress go to your dashboard/admin than from Appearance choose ‘Editor’ where you can access all the PHP files directly & choose the header.php and simply place the Analytics code there so every activity is carefully tracked via Google Analytics.

Placing Google Analytics code in WordPress

Adding Google Analytics Code in Magento

Whereas in Magento there are default configuration settings and Google API allow easy management for placing Google Analytics code in Magento.

Magento supports both pageviews and E-Commerce tracking a advance version of performance tracking from Google.

Enjoy more Interview and Questions for getting regular information now!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *