Where is the best place to insert the google analytics code in WordPress?

W

Every site needs to track traffic, therefore Google Analytics is here. Our question is, where is the best place to insert google analytics code especially in WordPress? Is the best place header or footer?

Google recommendations:

Paste it into your web page, just before the closing </head> tag.

One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. It is customary to place JavaScript code in the <head> section, and we recommend placing the snippet at the bottom of the <head> section for best performance

Google recommend to putting your Google Analytics code in WordPress just before the closing </head> tag and this is the best place. Edit the header.php in /wp-content/themes/your_theme/ and put the code into.

The code in <head> will add a little latency but Google Analytics code in the footer will reduce the number of pageviews recorded at some small margin.

Bonus:

To adding your Google Analytics code in the <head> also comes with the added benefit of being able to verify Google Search Console without any other manual verification methods.

Add comment

Recent Posts

Categories

Recent Comments

Archives

Tag Cloud