jGoogleAnalytics – Google Analytics integration for jQuery
This post has moved to jGoogleAnalytics – Google Analytics integration for jQuery. Please update your bookmarks
has moved to http://davidsimpson.me/
This post has moved to jGoogleAnalytics – Google Analytics integration for jQuery. Please update your bookmarks
[...] to support the new ga.js script from Google Analytics. Hence, I am very interested in trying out dvdsmpsn’s jGoogleAnalytics plugin, which not only converts my original plugin to work with ga.js, but also adds a slew of additional [...]
Wheel 2.0: Jason Huck’s Devblog » Expanded Google Analytics Plugin
July 2, 2008 at 10:15 pm
Hi,
Thanks for this, it looks like a good upgrade from Jason Huck’s code, I’m interested how I can track events that only happen on a single page (so shouldn’t be wired up throughout the site). e.g. Upselling, at the moment we do this onclick: javascript:urchinTracker(’/upsold/false/Some-Item’);
Is that possible with your code?
Tim
Tim
July 8, 2008 at 2:59 pm
Great stuff!
Bert
July 18, 2008 at 12:11 pm
Tim: If your upselling links had a parent container with a class name of “upsell”, e.g.
[ul class="upsell"]
[li][a href="http://example1.com"]Example 1[/a][/li]
[li][a href="http://example2.com"]Example 2[/a][/li]
[li][a href="http://example3.com"]Example 3[/a][/li]
[/ul]
…sorry for the square brackets
Your call to jGoogleAnalytics would be:
$.jGoogleAnalytics( 'UA-XXXXXX-X', evalClickEvents: {'.upsell a': "'/upsell/'+ $(this).text()"} );
This registers a click event for each anchor in the .upsell container, evaluates the link text and send it to GA.
The page impressions in GA for each link above would read:
/upsell/Example 1
/upsell/Example 2
/upsell/Example 3
dvdsmpsn
July 18, 2008 at 8:20 pm
Thanks for getting back to me, I’ve done something similar however as my upsell links are image buttons (so no text) I’ve done the following (the user has the choice in upgrading or not hence the true/false):
$.jGoogleAnalytics(
‘UA-123456-7′,
{
evalClickEvents: {
‘.upsellt’: “‘/upsell/true/’ + $(this).attr(’title’)”,
‘.upsellf’: “‘/upsell/false/’ + $(this).attr(’title’)”
}
}
);
And here’s the relevant HTML:
But I can’t see the upsell being logged anywhere in Google (but the page hits are).
Any ideas?
Tim
Tim
July 21, 2008 at 10:00 am
Ops sorry about the html (with square brackets):
[a href="/order/?li=241&vi=167&act=add" class="upsellt" title="Classic+Wax+100g"][img src="/img/bYes.png" /][/a]
Tim
July 21, 2008 at 1:32 pm
Great plugin! Thanks! One problem though…
Using $.getScript will reload ga.js from google every time a page is requested. I fixed it by creating a function with the following code:
return jQuery.ajax({
type: “GET”,
url: gaScriptURL,
dataType: “script”,
cache: true,
success: function() { setupTracking(); }
});
The essential part is to pass parameter cache: true. Now, jQuery will not force reloading the script every time.
Harri Kauhanen
September 28, 2008 at 7:23 pm
@Harri:
Thanks. I’ll get it updated.
dvdsmpsn
September 28, 2008 at 11:11 pm
I just wanted to say thanks. We have this in testing over on our site and it has worked like a dream. I’ll let you know when we get a compressed version uploaded.
Erik Karulf
October 14, 2008 at 2:53 am
@Erik:
I’m glad it’s working for you – please let me know the sites you’ve got it on.
Sorry – I guess I could have compressed it, but when we build our javascript, we compress many files into one, so it’s of no use to me
dvdsmpsn
January 30, 2009 at 9:51 pm
Where is the outgoing links info displayed in GoogAnal
eleventh.attempt
March 27, 2009 at 9:28 pm