Very cool! This seems quite useful. Do you have any examples it in action?
--John On 10/25/07, jason <[EMAIL PROTECTED]> wrote: > > I've been working on a jQuery plugin to simplify the process of adding > Google Analytics tracking to a page. The bulk of the code came > together pretty quickly, but I've run into a strange snag that's kept > me from finishing it off. > > Here's what the plugin is intended to do: > > - Determine whether to include the SSL or non-SSL version of the GA > script. > > - Include the GA script (currently urchin.js, soon to be replaced by > ga.js) from within try/catch to help suppress any issues GA may have > from time to time. > > - Set the _uacct variable to your GA tracking code. > > - Call the urchinTracker() function once for the initial page load. > > - Examine all of the links on the page and attach onclick events to: > - External links. > - Mailto links. > - Downloads. > > - Call urchinTracker() when these links are clicked, prefixing them > appropriately. > > In addition to the tracking code, the prefixes used for each of the > link types above, as well as the extensions considered "downloadable > files" are configurable by the user. > > Using tools like Firebug and Live HTTP Headers in Firefox, I have > pretty much determined that all of the above is indeed happening > exactly as intended. I see the requests for urchin.js and _utm.gif go > out to Google on the initial page load, and another request for > _utm.gif for each click, and Google responds with a 200 OK. The > appropriate cookies get set, etc. I haven't picked apart every single > item in the query string attached to each call, but the few pieces I > understand well enough to verify appear to be correct. Yet, the hits > don't appear in my GA account. > > I posted to the Analytics Troubleshooting group and got a few replies, > but it's still a mystery to me. I think this would be a pretty handy > plugin, so I'm hoping someone out there can figure out what's going > on, or at least confirm with their own GA accounts whether tracking is > working or not for them. If you are interested, you can grab the > plugin here: > > http://dev.corefive.net/jquery/jquery.gaTracker.js > > It requires jQuery 1.2 or higher for the cross-domain $.getScript() > call. Usage is simply: > > $.gaTracker('UA-XXXXX-XX'); > > Or you can specify options like so: > > $.gaTracker( > 'UA-XXXXX-XX', > { > external: '/external/', > mailto: '/mailto/', > download: '/downloads/', > extensions: [ > 'pdf','doc','xls','csv','jpg','gif', 'mp3', > 'swf','txt','ppt','zip','gz','dmg','xml' > ] > } > ); > > Suggestions appreciated! > > Thanks, > Jason > >