Should Google Analytics go in the head or bottom of an HTML page?

前端 未结 7 1189
渐次进展
渐次进展 2021-02-02 12:14

Google advises putting the google analytics script right before closing the .

However, I would prefer to combine it with the rest my javascript

7条回答
  •  攒了一身酷
    2021-02-02 12:32

    I agree with the accepted answer. I would like to add that I noticed Google Webmaster Tools (GWT) requires the tracking code (asynchroneous version) to be in the head to be able to register as admin for your site via an existing Google Analytics registration for the same site. So if the JS tracking code is not in the , this registration option is not available.

    This might be Google's way of coercing more websites to do this. Perhaps Google can keep better track of precisely those visitors who cancel during page load. These might make interesting Analytics for them to optimize their search results (e.g. maintain 'early-bounce' events for their statistics).

提交回复
热议问题