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.