But now the style change and webmasters prefer to integrate the code in the header part.
It has many advantages as compare to the old method. We are going to discuss the advantages in detail one by one.
Easy to track the every single user.
Putting code in header help you to track every single session and page view. If you place the code in the body or footer tag there may be a possibility that you miss few session and page views.
On every single hit to the website URL you can track the session and page view. But if you place the code in the body/footer part it first load header element and then the body element. So, there may be the possibility that some time website don’t track the user properly due to low internet speed or due to heavy load time, user exit the website.
By putting the code in the header you don’t need to place code manually in every page to track the visitor.
Placing the code in the footer can improve the website loading time but will track every single session and page view.
In case you need more insight on how Google Analytics work, feel free to comment. We would be very happy to answer your query.