Easy Google OnClick Demo
Welcome to the demonstration page for the Easy Google OnClick Demo written by Scott Brooks at UserFirst Interactive. This is a very simple, low impact, jQuery plugin that allows you to add Google onClick tracking with a couple simple lines to your site. Even if your links already have OnClick code, the tracking will just be appended to the existing code without breaking what already exists. Below are some samples of how it's used:
Usage
Variables:
analyticsaccount - your Google Analytics account #
referenceBy - acceptable values: "href", "html", "title", "name", "id" or combinations "location|href", "location|title", "location|html". If a combination is choosen, then the output in analytics looks like so:
For "location|href":
/LOCATION/current/page/location.html/HREF/www.theurlofthelinktracked.com/
For "location|title":
/LOCATION/current/page/location.html/TITLE/thelinktitletag/
For "location|html":
/LOCATION/current/page/location.html/HTML/click here/
onlyTrackClass - (optional) if you only wish to track links with a certain class name, use this
trackprefix - (optional) prefix text added prior to the tracking link reference. i.e. "/click/"
trackpostfix - (optional) postfix text added after to the tracking link reference. i.e. "/outbound/"
Sample Code
Standard usage for tracking links:
$(document).ready(function() {
$("a").easygoogleonclick({
analyticsaccount: "UA-XXXXXXX",
referenceBy: "location|href",
trackprefix: "/click/"
});
});
the above configuration allows you to see which page the links are clicked on, as well as where those links are pointing to. So for instance, say you have a banner ad and you'd like to know on which pages this ad is most effective. This would allow you to see which pages the banner ad was clicked on the most.
Or, say you want to just handle tracking of outgoing links, then you could use a class based configuration:
$(document).ready(function() {
$("a").easygoogleonclick({
analyticsaccount: "UA-XXXXXXX",
referenceBy: "href",
onlyTrackClass: "outgoing-link",
trackprefix: "/click-outgoing/",
});
});
Any links you add the class "outgoing-link" to will then be tracked and would track the click as something like: /click-outgoing/www.theoutgoinglink.com/
Overall, this makes for much more robust click tracking and will help you get a better reading of what your users are clicking on throughout your website.
Download
Plugin
Requires the jQuery URL Parser (included)
Download version:
alpha 0.8 - js files
Questions? Comments?
We'd love to hear from you! Visit our blog and let us know what you think of our creations!
