views:

1959

answers:

6

Hi, I am willing to use Google Analytics to track stats about usage of my Client/Server application (no Browser on the user computer!).

So I guess if anyone ever tried to craft requests to __utm.gif from serverside code.

I have found some information on the request and relevant cookies at google website but there are no details on the cookies values passed in the "utmcc" variable.

I understand that I will not be able to "craft" some of the information which Analytics server derives from the request itself (one for all: the source IP address!). I can't generate requests from the Client computer.

Does anyone have experience with this scenario? Any detailed information or resource? Any working code snippet (any language will do! :)?

Thanks!

A: 

Interesting requirement...

Your best bet would probably be to attempt to reverse engineer the google analytics javascript a little...

With firefox, and firebug, go to a web site that uses google analytics then open firebug and look at the GET that is submitted to google analytics. If you can then create an HttpRequest with those same parameters and headers you should be able to fool google analytics into thinking you're coming from a web page.

Michael Wiles
Yes! That's the hard way! :) I was hoping someone already went down that path!Anyway, I will report here any finding if I will need to go with reverse engineering. Thanks!
Pokot0
+1  A: 

From inspecting my cookies in firefox for a site that is a known user of google analytics I see it stores 3 values (all 3 start with 2 underscores):

  • __utmc - 9 digit integer (probably)
  • __utma - very long integer with periods thrown in (starts with 9 digits above)
  • __utmz - long string period seperated (starts with 9 digits from utmc)

My guess is utmc is your tracking session id.

Hardwareguy
+3  A: 

I asked a similar question recently and somebody gave me a link, and I found another from the same site:

http://www.vdgraaf.info/wp-content/uploads/image-url-explained.txt
http://www.vdgraaf.info/wp-content/uploads/urchin-image.txt

I haven't fully tested it yet, I'm still working on implementing it. Also, it seems like it's a little old and there's no documentation of how to log events, only page views.

Andy E
interesting stuff! i will do some tests and let you know what I have found. Thanks!
Pokot0
it worked like a charm. I have just tested basic functionality for the time being, but definitely seems promising! Thanks!BTW: Here is the link to the original article for anyone who might be interested:http://www.vdgraaf.info/google-analytics-without-javascript.html
Pokot0
the links are dead unfortunately.
Mo Flanagan
Tried right now. Seem to work fine. Maybe a temporary disrupture!
Pokot0
A: 

Embed the script in an HTML page with variable placeholders for page title and such, then load the page in an embedded IE instance server side. The GA script allows you to track page events by specifying parameters to the main tracking function, so all you'd have to do is keep the template HTML page in memory, replace the placeholders, and load the page in the embedded IE instance. The IE instance would parse and execute the javascript like it were a normal page and bingo, you've got your tracking.

This is theoretical, of course, and not tested.

Chris
Thanks Chris,this is an interesting approach. I have done some thinking and I think it needs to be a little more complex than what you explain. In order to track visits/visitors correctly (and most likely for many other functionalities) you need to preserve cookies for different users. So I would need to save cookies serverside and use the same cookieset everytime the same user triggers an event. I will do some more thinking and maybe some tests using http://lobobrowser.org (I have java serverside) or selenium using different profiles.
Pokot0
A: 

Hello, Is there any updated documentation for this. I am trying tracking analytics events with ASP.NET. I need to track some events in the Server Side after some functionality is completed on Server Side. How to adjust this on Server Side. I am a newbie on this? Appreciate help regarding this.

Thanks, Raj

Hi Raj, the links in "Andy E" answer (and relevant comments) are the best I have found. The code snipped worked for me for the last two months, even if I only tested very simple events for now (basically: visits). I will write an update if I ever have the time to test more complex scenarios. Anyway, those links look like a very good starting point.
Pokot0
+3  A: 

you might want to give http://code.google.com/p/serversidegoogleanalytics/ a try. its working for me (in combination with zend framework for the http request).

schellmax
Very nice project. Exactly what I was looking for (i wonder if it was already available when I first submitted this question!).Anyway, it seems to be in its early stages and only a limited number of attributes of the pageview can be set (no OS, no Flash version, etc). Thanks for the link!!!
Pokot0