Google Analytics: free advanced website statistics
budda - November 15, 2005 - 13:15
Just released a simple but effective module to add support for Google Analytics on your Drupal powered site.
I'm using it already on BargainSpy without problems, although Google Analytics does seem to be a bit dodgy at the moment with stability on their site.
You can pick it up from http://www.ixis.co.uk/drupal-modules/google-analytics

Thanks !
Thanks !
Was Previously Urchin
Google analytics is essentially Urchin, the analytics company they bought earlier this year. I've been testing it at my job with search engine management and it has a lot of interesting features. Parses the keywords, can show you good traffic stats and track some variables or "conversion" pages. There are limitations, however, since it runs off of javascript and is not processing your log files. You won't get a picture into bot traffic to the site or what a user does who does not use javascript.
Still, its a great value to get a complex program like that for free, considering it previously cost a significant amount!
decon
Processing logs
I remember using Urchin a few years ago (5-6) when it was on version 2-3 and it had the functionality to parse apache logs.
Do you think this will arrive for Google Analytics (in fact apache logs are not meant to be used in such web service... but who knows).
Logs & Urchin
Well, Urchin can process logs - but not with the hosted version (I'm pretty sure). There has been a much more expensive software option which you could run on your own server and have direct access to the logs and other processing options. Urchin hosted was the cheaper route in which you paid a per month fee based upon your traffic. The javascript code collects data about the visitors and sends it back to the Urchin server which organized the data and had it available for use the next day. The only way to really get at logs is either to load them directly from the machine or to have another server which is pulling the log files in from apache or whatever your web server is. Some of the more expensive analytics programs directly ftp over and only pull down the data they need from a log file. On a server with a lot of traffic the log file can grow pretty fast...
Useful
thanks, Very useful and simple mudole .but I prefer to use internal stat logs drupal mudole,
-----
www.PersiaData.com
Yes
Yes. Thanks!
I'm learning how to make
I'm learning how to make a Drupal module by looking at this code. :)
Great for learning....
Marcel
http://www.macminiforums.com
http://targetedpixels.com
Why not use _init ??
My method was to use an _init hook, see this forum thread: http://drupal.org/node/37786
- David Herron - http://7gen.com/
According to the docs it
According to the docs it suggests the hook_menu()
Which sounds like just what is needed.
Using the hook_init() causes problems with pages which are cached by Drupal. I used hook_init() in the nodewords.module and this breaks with caching.
--
www.bargainspy.co.uk | More Drupal modules
The module doesn't work in
The module doesn't work in my drupal-powered website. I don't know why. After enabling it and entering my account number, I still got the following message from google analytics:
Tracking Unknown
The Google Analytics tracking code has not been detected on your website's home page. For Analytics to function, you or your web administrator must add the code to each page of your website.
Did anybody else encounter this problem?
--------------------------
http://www.kzeng.info
Yes
Yes,
I thought I was going nuts; tried the code everywhere.
But time and patience was all needed to resolve it ;-) Apparantly Analytics is very busy and a bit shaky now and then. It took >10 h after adding the code before 'Tracking unknown' changed to 'waiting for data'.
--
Tips for posting to the forums
Everything started working
Everything started working at Google's end this morning. Woo.
--
www.bargainspy.co.uk | More Drupal modules
Message from google
Got this message today at my Analytics account:
___________________
discover new oceans
lose sight of the shore
Woot!
____________________________________________________________________________
Blog - Sydney News, Current Affairs, Photography, Travelling & University...
others' experience
i signed up for it a three days ago, inserted the javascript into my template and still get the "Tracking Unknown" error.
anyone else experiencing greater than 24hr delays?
--
Living in fear of patch hell?
Want a stable development environment?
Support Dev Releases: http://drupal.org/node/30903
Support Code cleanup too: http://drupal.org/node/28540
Why is the code displaying?
So I signed up, turned on the module, gave it my tracking number, used the footer field in settings to implant the code... and google says it's tracking my site...
...but how come the code is actually displaying visually? I've got "_uacct = "UA-296245-1"; urchinTracker();" at the bottom of every web page on my website. I assumed the code would be invisible to my visitors. Have I done something wrong?
My report on setting up google analytics
So, after a couple days of confusion, I have a report on getting google analytics to work.
1. The module inserts the code for you. Google gives you an account id. You just have to enter this into the module settings. This should be very straight forwards.
2. The problem I encountered was due to the URL I was giving google. It considers www.playpoi.com, playpoi.com, and www.playpoi.com/ to be different URLs. When I entered www.playpoi.com it couldn't find the tracking code until I entered it using the footer field under settings. Except then it still didn't have any data on my site after over 24 hours, and I had the tracking code showing up at the bottom of every page of my site, visibly.
I then viewed the source for my home page, and there was the tracking code, twice. I removed it from the footer, and checked again. There it was, once, exactly where it should be, and exactly where the module put it. Great. But then when I went to google analytics it said the tracking code was no longer installed!!!
Finally, on a hunch, I set up a new account, this time with www.playpoi.com/ instead of www.playpoi.com. Everything worked after that. I'm happily analysing traffic, and I now live on a big yaught and have two wives.
...ok, I made up the bit about the monry, yaught and wives, but I am happy to be using google analytics.
Note: Google Sitemaps is picky about website URLs in much the same way.
n
Do not include the <script> tags
In the advanced window it states:
Do not include the
<script>tags, and always end your code with a semicolon (;)The Google Analytic code is:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-xxxxxx-1";
urchinTracker();
</script>
Does that mean I need to remove all of the
<script>and</script>tags?Or just the two
</script>tags?If I paste it as is, 'urchinTracker()' is displayed on the bottom of the page.
Any help would be appreciated.
Thanks...
If you are not doing
If you are not doing anything advanced, you don't need to be using this text area!
From the code you posted, it looks like the standard stuff which is built in. Just enter your UA ID in the module settings.
--
Ixis (UK) providing Drupal consultancy and Drupal theme design.
Can't use footer
Drupal's footer is not interpreted as full HTML. You can't use that.
I'm experimenting with blocks and a completely HTML filter, but I'm currently not using the module. If you use the module, do not insert Google's code. The module does that already.
Hans-Georg
Trailing slash
That would be an incredibly stupid defect in Google Analytics. I must say that I find it hard to believe and would look for other causes.
Perhaps it would have worked anyway after a while. I'd wait for 24 hours first.
Hans-Georg