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 place Google Analytics Code? [Official Recommendation]
- Google Analytics Tracking Code
- Google Analytics Header or Footer code
- Google Analytics Tracking Code for Website
[HTML Static & Dynamic Websites]
- Google analytics tracking code WordPress
- Google analytics tracking code Magento
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.
Understanding Google Analytics Tracking Code
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.
Google Analytics Header or Footer code
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.
- 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.
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.
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.
Enjoy more Interview and Questions for getting regular information now!
- HTML5 Interview Questions and Answers for Freshers
- CSS3 interview questions and answers for Freshers
- Bootstrap 3 Interview Questions and Answers for Freshers
- PHP interview question and answers for freshers
- Responsive Web Design Interview Questions And Answers for Freshers
- WordPress Interview questions and answers for freshers