I have always put the Google Analytics code before the </head>. I figure it’s their code and that’s what they recommend, so might as well follow that. I know a few analytics plugins I’ve used also place the code there, so you shouldn’t have any issues following Google’s instructions.
Loading an external script file in the head is common…if you have inline javascript, it should be placed just above the closing body tag.
Some scripts need to be loaded in the head for the ‘content’ to work, some can be deferred as noted (as they have no affect on site content).
Many optimization tools do not review ‘what’ the js actually is or does and just make general comments to load in ‘footer’…
What you do want to avoid is loading inline javascript in the head.
If your site properly allows caching of the external js files locally, your clients’ browsers will not have ‘get’ them on subsequent page loads.
Thread Starter
Monica
(@monica4567)
Thank you for your responses! I never got any notice that I had received responses, so I just checked here wondering about that. Must be a setting.
Anyway, I don’t know much about coding, so the second answer is a little beyond me – wouldn’t know “inline javascript” if it hit me in the face – so I’m going to follow the advice of the first response! Sounds easy enough. If I have problems, I’ll be back!
Thanks!
Thread Starter
Monica
(@monica4567)
Mission accomplished, I think, but I have a question: what’s the difference between header.php and header-admin.php? And if I want to track my About page, is there a separate page to insert the tracking code? Or does the header hit every page? (that’s right, not a coder, or anything like that)
thanks!
header.php is one of the template files in your theme. header-admin.php is a WordPress core file and should never be edited.
Thread Starter
Monica
(@monica4567)
Thank you for that critical bit of information. Never edit the admin files! Check!
So it sounds like I did it right. We’ll see if it actually works…
can anyone help me on the question above? I am new to WP and i want to insert the Google Analytic codes just before the header.
Thanks
So I have watched video’s, read the forums and still cant get GA to track anything. It has been about 12 hours since doing so and still nothing. I placed my GA code right before
</body>
</html>
in the footer section.
How long does it take to start getting results? This is for a self hosted site via GODaddy.
the first responder suggested placing the code right before the
</head>
I cant find this. do I need to p;ace it there instead?
Thanks for any further responses
also, do i need to disable site stats with jetpack?