Orange is my favorite color

I found myself wondering, “If we require Javascript, how many people will we screw (and what will the customer service burden be)?” For most answers, we turn to Google Analytics but unfortunately, being Javascript-based, GA doesn’t capture that information.

That is, until Remy Sharp sorted it out two weeks ago by manually constructing a __utm.gif reference that uses an image inside of a <noscript> tag. The code is straightforward but I’ve ported it to CF as a shortcut if you find yourself in the same situation. Check Remy’s post for the details.

<cfsilent>
<cfscript>
var_utmac = 'UA-12345-6'; // your identifier
var_utmhn = 'http://www.mydomain.com'; //enter your domain
var_referer = CGI.http_referer; //referer url 

var_utmp = '/noscript'; //this example adds a fake file request to the (fake) tracker directory

var_utmn = randRange(1, 9) & randRange(100000000, 999999999); //random request number
var_cookie = randRange(10000000, 99999999); //random cookie number
var_random = randRange(1000000000, 2147483647); //number under 2147483647
var_today = int(getTickCount()/1000); //today
var_uservar = '-'; //enter your own user defined variable

urchinUrl = 'http://www.google-analytics.com/__utm.gif?utmwv=1&amp;utmn=#var_utmn#&amp;utmsr=-&amp;utmsc=-&amp;utmul=-&amp;utmje=0&amp;utmfl=-&amp;utmdt=-&amp;utmhn=#var_utmhn#&amp;utmr=#var_referer#&amp;utmp=#var_utmp#&amp;utmac=#var_utmac#&amp;utmcc=__utma%3D#var_cookie#.#var_random#.#var_today#.#var_today#.#var_today#.2%3B%2B__utmb%3D#var_cookie#%3B%2B__utmc%3D#var_cookie#%3B%2B__utmz%3D#var_cookie#.#var_today#.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D#var_cookie#.#var_uservar#%3B';
</cfscript>
</cfsilent><cfoutput><noscript><img src="#urchinURL#" /></noscript></cfoutput>

If you’re wondering what is the deal with the two randRange()s concatenated together, it’s because ColdFusion’s randRange() function doesn’t like numbers greater than 2,147,483,647. In order to get a number up to 9,999,999,999, I’m putting the two together.

You can read some more behind the values attached to the image at http://code.google.com/apis/analytics/docs/tracking/gaTrackingTroubleshooting.html.

6 Comments

  1. Derek said:

    on November 4, 2009 at 6:03 am

    but, if GA shows 98% have javascript on, wouldn’t you conclude that 2% do not?

  2. Brian said:

    on November 4, 2009 at 7:56 am

    @Derek – since GA is javascript-based, it only reports data for people with Javascript enabled. E.g., 100% of GA data is Javascript enabled. This approach lets you get that 98/2 breakdown.

  3. Derek said:

    on November 7, 2009 at 7:11 pm

    oh ya, duh. brain fart. :)

  4. Erik Vold said:

    on November 8, 2009 at 6:59 pm

    Hey,

    I’ve started a GA.CFC which is available at GitHub here: http://github.com/erikvold/GA.CFC if anyone reading this is interested in developing this further.

    I also wrote a bit about my plans for the future of GA.CFC here: http://erikvold.com/blog/index.cfm/2009/11/8/start-tracking-javascript-disabled-visitors-with-gacfc

    Which, briefly, is to port the Visitor tracking, Page tracking, Event tracking (those events capable of being recognized by the server that is), and more GA features to GA.CFC from GA.JS

  5. Brian said:

    on November 9, 2009 at 9:26 am

    @Erik – do you have any thoughts about using the image-based approach to record, say, email opens as well?

  6. Erik Vold said:

    on November 9, 2009 at 8:38 pm

    @Brian I haven’t given that much thought, but if you prepare the img source the use for the email before it’s sent, then each view of the email (where images are allowed) would show up as a new visit w/ one page view of a page name that you can make up. So each recipient could ‘convert’ multiple times. You could give each recipient a unique page name (having it include their email) but that might be breaking GA terms..You could also have the emails make img calls to a server you control, then have the server make the img request to GA servers. Where the img request to your server includes the email used, and the img request to the GA server does not, in which case you could ensure that each recipient only converts a single time. One problem I see here is that the ip would be your server, so the location of the visit would be the location of your server..

{ RSS feed for comments on this post}