Where NOT to put your Google Analytic Code!

It’s not rocket science. I am not a pet. What I do is solid coding šŸ™‚

Few days ago one of my clients wanted me to put analytic code at the bottom of his website. So I had to write a log email for him. I am just gonna writeĀ this article based on that email ( you all know I am a busy man and I like to save time when I can šŸ™‚ )

What was my clients logic?

He wanted me to make his website super fast. He read that if we place the java-script at the bottom of the page it increase page speed. Well, he was right. So what was the play here? If we place the code at the footer ( just before the </body> tag that means the code will loadĀ last. That means the page will load faster and once the page loaded the js files will be loaded. No bigĀ deal right?

Hell, no. Here is my logic

What actually analytic do? It track people on your website, what they do, how long they stay etc… ( I know, you all know about this ). Say your website loads within 10Ā seconds. It means ifĀ you place the analytic codes at the bottom theĀ analytic code will load after 10Ā seconds of your website loaded. That means google willĀ blind for those seconds. So it will not track any visitors data for those second and it is too bad for your SEO. Your visitors might have click a link within that 10Ā seconds and google will never known about it ( you see, even 10Ā second is here important ). Also you will loose average session duration smaller than the actual time your visitors are spending on your website.

You see my point. If you are going to save 1 second actually youĀ areĀ loosing more to be invisible to google šŸ™ Too bad, right?

Where should I place it?

Before the <body> tag. In our WordPress themes we already applied it long ago. Visit here Appearance >> Theme Options >> General Settings >> Google Analytics Code. Just place the code as it is and you are done.