Google analytics?

Grabahost

New member
It's silly but I couldn't find the place to put Google analytics code on one of my Wordpress blog. It should be in the head section, right? It must be the theme I am using, because I couldn't find the head section from the editor page.
 
Google Analytics should NOT go in the header - you want this to be the last thing to load. You want all scripts as close to the bottom as possible so that it doesn't negatively affect the page loading times on your site.

There are a number of Google Anayltics plugins that you can install into Wordpress, but as you mentioned, you'll want to check the Theme that you're using. Sometimes it's included in the Theme, sometimes it's not.

Either way, you can easily just add the code into the FOOTER of your site - not the header.
 
Google analytics code must be in header. It was with old google analytics code that people used to place it in footer.

This is new asynchronous code which one should put just below closing </head>. If you have a javascript above google analytics code then its possible that if the above script failed to execute then google analytics may also respond as error.

This is a asynchronous google analytics code and if there is any error in the code for the time being , your site will load properly without hanging or showing errors. Thats why its called as asynchronous tracking code

Placing asynchronous analytics tracking code in <body> have proved that their data is missing or not correct.

So my suggestion would be open wordpress header file and place the tracking code there...:)
 
Last edited:
Thanks for the advice guys, though I am a bit confused now. I would love to place the code on the footer if it is what I were supposed to do.

Anyway Bullten, does it mean I need to modify the core Wordpress file?
 
I've always placed mine in the header, before the closing </head> tag.

You don't need to do any file editing, you should be able to add the code in via the theme editor in Wordpress. Look for the header.php file and then paste the tracking code in there (before closing </head>)
 
follow the instruction of chisi and place the code in respective place. Remember you are going to use asynchronous code and before </head> is the right place for it if you don't want the data go missing.
 
I've always used the bottom as I never want to track a page that only partially loads (or a bounce in that regard).

Going to Google's current page at http://www.google.com/analytics, and then clicking to the option about how to install it, you get this page;

http://support.google.com/googleana...gn=en_us&utm_source=DiscoverList&answer=55488

This is for the traditional method (installing at the bottom before </body>)

There's then a link on the page to the NEW method (asynchronous) where they say to insatall it before the </head> tag;

http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=174090

For us, we've always used the bottom of the page method.
 
Ah I didn't realise that there were two ways, useful to know. :) I wonder if there is any difference between the asynchronous and non-asynchronous codes?
 
There is a big difference. Several functions were combined together to for a single function where user don't have to write big syntax for each and instead of that he can use the function to pass the value. Search on google you will get idea.

I will tell you why the traditional code was placed in footer and new asynchronous was placed in header.

Well that code was a big problem for users when some thing goes wrong with GA tracking code. If that code returns error or suppose google analytics is down for a while and you placed that code in header then your page will not load completely. It will show only header and rest of the code stops and incomplete page is displayed to the end user . To overcome this they came to a conclusion that this traditional code must be placed into footer.

Now they had the challenge in front of them to resolve this issue.

Probability:
Suppose someone came to your site and by mistake his browser crashed or net got disconnected or he went away without the execution of analytics code which was placed in footer and his visit was never recorded. But why? It was a visit. Isn't it?.

To over come this google launched asynchronous code because when someone comes on your site the first thing gets executed is the header part.So, if Google analytics code fail to execute because of some error then also your site loads completely and thats why it was placed in header.
 
Last edited:
Top