I have installed google analytics on my sites in the index page of wordpress, but it comes up with a header error. What can i do to get rid of the error, maybe my analytics is in the wrong place, where should i install it? do i have to put something like <head> nglrenlg'neg tg re gre g </head>
The easiest way to install the code is to use the [TABLE="width: 142"] [TR] [TD="width: 142"]WP Google Analytics[/TD] [/TR] [/TABLE] plugin
Who said that ? Every script is basically better to place in the footer. Because it will be loaded after every other components loaded. It makes the website load much faster. Doesn't really matter where code is put it will achieve the same result. even if you put the google analytic inside the <body> it will be loaded fine. Obviously the best location to google analytic or other tracking code is before </body> tag. Because it will be loaded after everything else loaded.
Yeah I get that, but whosaid that put the code on the footer is not the right thing to do? As I said before, doesn't really matter where you put the code it will still works. But in best practice it will be best to put it on the footer.
Well, on the page I linked to is also this note, which explains why people should put the code to the <head> section:
it's also said that " It is customary to place JavaScript code in the <head> section" there you go. nobody , except you alone that said put the code on the footer is not the right thing to do. put the code on the footer is a perfectly right thing to do. the one who said that putting a script on the footer is not the right thing to do, doesn't really know how a JavaScript work.
I am not an expert on this issue but I would stick to their recommendation. GA gives more accurate data then and I doubt that visitors would mind if pages with the tracking code before </head> would load 5 miliseconds slower than in the case when the code is placed before </body>. People who prefer fast loading of pages use browser addons like NoScript anyway.
Sure thing, it is just a matter of preference. Whether to put the code in the head or in the footer, or even in the body, all of it just work the same. The script will load and works fine. The only difference between them is the execution order. Nothing else. As long as the page fully loaded all of them give the same results. For people who got fast internet connection sure doesn't tell the difference. But for people who has slow internet connection (like me), sure can tell the difference. I often experience when visiting a website, on the status bar of my browser I "waiting for analytics.google.com" and left me staring a blank white page. Wouldn't it better to load the content of a website and load the script later, that way the visitor doesn't need to stare the blank white page. Most modern template has already doing this. Loading the main content first, and then loading the rest (images, slider, script, tracking code, jquery, etc).
For me, no script is no way to go. Make the browsing faster by sacrificing browsing experience ? that's not definitely my style. Imagine, no script means, no ajax, no jquery, no javascript, no interactivy. It is so 1900. Back to GA. If you want to stick with the GA recommendation, it's your choice. I don't really care about what you do. I am not going to force or anyone out there to use my style. Back to the real problem, I am not agree with your statement here. Even GA never said that a footer is not the right position for the code.
Hi, its very hot interesting discuss. I just got a lot info and I liked to try all you suggest. Thank you guys.
Put the code in the footer. That serves the same purpose unless, if there is any bloackage to the footer. Header is always recommended
Agree, put the code in the header is well recommended to make more reliable real time show result in google analytics. But putting the code in body or in footer is also OK. Make sure to also install and activate plugin named "Google Analytics for Wordpress". Last step is in the plugin, click settings, then in "Analytics Profile" part thick "Manally enter your UA code" (login to analytics.google.com then find your UA... code), then enter manually your UA code. Guaranteed work.
Download this plugin from google or wordpress... [h=2]Google Analytics for WordPress[/h] it works fine