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?
Paste it into your web page, just before the closing
<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.
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.