mHelmy 0 Report post Posted November 4, 2007 Are there any different tracking results when placing google analytics tracking code at the beginning (after <body>) or at the end (before </body>) ?I post this question because I think a heavy site will load slower so it can be failed to load all site's contents and GA tracking code at the end of the site will not be loaded and it will affect the counter.Any experience about this ? Share this post Link to post Share on other sites
vujsa 0 Report post Posted November 5, 2007 Well, I started using Google Analytics three days ago since my built in web stats component is using a very large amount of space in my database. I wanted to find a way to replace it and save the space used so I signed up for Google Analytics. I did as suggested and placed my tracking code right before </body>.There is a very large difference between what Google shows my traffic as and what my built in system. For example, yesterday, my built in system told me that I had 2684 page views (not visitors but actual page loads) but Google only shows 773 page views. I checked the server logs and found that 2684 was the correct amount.Maybe I'll try placing the tracking code at the beginning of the page instead of the end and see if it helps.I would have to say that other than the fact that Google Analytics is incapable of providing accurate statistics, the tool does offer a lot of insight to traffic patterns on your website. The bounce rate alone tells you whether or not the content on your pages is useful or not. Having a better idea of where your visitors come from and a clean organized way to view your stats is priceless.vujsa Share this post Link to post Share on other sites
Chesso 0 Report post Posted November 5, 2007 Wow that sounds good, I haven't heard of this yet.But that is a nasty little innacuracy.I would probably contact them and explain it, there might be a good reason why. Share this post Link to post Share on other sites
mHelmy 0 Report post Posted November 5, 2007 and by the way, google analytics tracking code is a javascript code. so it won't count traffics from non-javascript browser.I also have built in wordpress statistic using a plugin, and it records all traffics.But I heard there are some visitor tracking softwares in cpanel, maybe they can be more accurate.From replies above, google analytics seems useless. But look at html page source of this forum, google analytics tracking code is placed right after <head> tag... Share this post Link to post Share on other sites
Chesso 0 Report post Posted November 5, 2007 Oh right that makes sense about the JS code.Is there not an alternative method that is more reliable?Can PHP be of any help possibly? Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted November 5, 2007 One thing to remember is that Google Analytics (I believe) uses a slightly different definition of "page view" than we do. I'm not sure why, but it's the only thing I can think of for the discrepancy. I've been the only person (pretty much) looking at my site while it undergoes development and testing, so I know very well how many page views there are, upwards of 100 because I keep refreshing. Google Analytics doesn't count many of these as separate page views, instead, it seems to simply keep that count as time on the page. So perhaps for each visit, a jump from homepage to another page back to homepage counts as 1 view, since it is one person viewing the page on one visit, even though it is two loads. I think that is how the calculation is done. It doesn't seem to be total page views, but visits to that page. Also, I haven't noticed a difference depending on where the code is placed. I agree that the end is best, because it doesn't cause a slowdown of the page loading.  Edit: I just stumbled across something on the Google Analytics help that confirms this.In Analytics, if a user comes to your site twice within thirty minutes without closing their browser, they'll register as one visit. Other web analytics solutions may treat this behavior as two visits, depending on their definitions.For the full article, which explains in pretty good detail differences between analytics and other stat generators, see this help page. ~Viz Share this post Link to post Share on other sites
Chesso 0 Report post Posted November 5, 2007 Ahhhhh yes that would certainly make sense.Although it slightly complicates the data lol. Share this post Link to post Share on other sites
ethergeek 0 Report post Posted November 5, 2007 I always put my GA track code at the bottom of my pages...the reason being, is that I don't want the script load tying up my page load on browsers that don't pipeline and evaluate the JS before building the DOM (most mobile browsers).I've noticed that the GA code can sometimes be very slow to load...and if it makes the page unusable, then all GA is gonna see is the visitor that won't ever come back Share this post Link to post Share on other sites
Arbitrary 0 Report post Posted November 23, 2007 In Analytics, if a user comes to your site twice within thirty minutes without closing their browser, they'll register as one visit. Other web analytics solutions may treat this behavior as two visits, depending on their definitions.Ohhh, now that would explain very well the huge discrepancy. I was thinking that there couldn't be a few thousand visitors to vujsa's site that disabled javascript or didn't load the page up to the beginning of </body>. So basically Google Analytics only registers unique hits rather than all hits. I suppose, though, some people may find it more useful for Google Analytics to register both unique and all hits just so they can see the differences. Can PHP be of any help possibly?Yeah, if you were doing it on your own server, you could definitely use php to keep track of hits. But Google can't since it's doing it from theirs. They basically have to use javascript because they don't have access to your server. Which basically means that their hits would be off by a bit (probably not that much off since not that many people actually disable javascript.) Are there any different tracking results when placing google analytics tracking code at the beginning (after <body>) or at the end (before </body>) ?  I post this question because I think a heavy site will load slower so it can be failed to load all site's contents and GA tracking code at the end of the site will not be loaded and it will affect the counter.  Any experience about this ? While this may be possible, I don't think it's all that likely that it would actually happen. But just in case, it's probably better to put the code at the beginning of your site just in case. Share this post Link to post Share on other sites
muztagh 0 Report post Posted December 10, 2007 I have found a tip on the web and tried it and the page load became faster.The tip is host the "urchin.js " file locally means download it from the google website and upload it to your web server, and do not forget to update the link in the google analytics tracking code. Before it is "http://www.google-analytics.com/urchin.js; now it should be "http://forums.xisto.com/no_longer_exists/ reason behind this technique is some times google analytics website may be very busy and loads the urchin.js file very swlowly on your website but if you place it on your server it will be downloads at the same time with your webpage and does not effect the speed. I found it extreamly conving especially for websites hosted far from google data center. Share this post Link to post Share on other sites
Quatrux 4 Report post Posted December 11, 2007 Google analytics is very good if for example your server doesn't have somekind of a stats software or you use only html and don't know anything about server side scripting, even though I agree that using statistics on your website takes much of webspace, then I was logging everyone into the database, after 12 months you can really have lots of data, from that time I prefer to use simple text files for logging a user page view and just using different names, from all that data you can make and see whatever you want with little bit of coding, of course if you don't log every visit, but just make the counters count and store the ip addresses or something, then I guess a mysql is the right choice or if you like that your mysql database gets over 50 MB or even much more then it's also good, I guess databases are meant to do that, but I still prefer to use text files database for this purpose. Share this post Link to post Share on other sites