Making All Internal Link Clicks a Conversion

A common use case of Google Website Optimizer (GWO) is to test (in order to optimize) a page's ability to have a user click an internal link, I like to call this the internal pass thru rate of a page. Meaning the click event of any internal link on a test page will count as a conversion for the test. This is not the opposite of the bounce rate which it is sometimes mistaken for, because the pass thru rate is oblivious to the difference between first time visits and other visits. The pass thru rate is not the same as the click thru rate either, because the pass thru rate relates to visits and the click thru rate relates to impressions. This is usually desired either because you have no other conversion to track -- although time on page is always another option, but the results typically take longer to acquire -- or because you wish to optimize the bounce rate, and this is as close as you can get at the moment.

Google doesn't have any documentation on how to track all internal links on a page, but they do provide a page on how to track an individual link, which any novice JavaScript programmer can follow in order to track all of the internal links, by simply repeating the process for every internal link on the test page(s). The main problem here is that Google's process requires that the onclick attribute of every link be set to "return false", albeit this can be done via JavaScript, it is not desirable. Google Website Optimizer's Technical Lead Engineer, Eric Vasilik, explained Google's method in a blog post from August 2009, called "Tracking Outbound Links -- The Right Way", and I wrote a follow up post in December 2009, called "Tracking Outbound Links - The Really Right Way" in which I describe a better method which is slightly harder to implement but does not require any use of the onclick attribute.

If you are at least a novice JavaScript programmer that wants to measure the pass thru rate of a page, then you can probably implement Google's method or mine with relative ease after reading the blog posts I mentioned.

If you are not a novice JavaScript programmer, or simply want to save some time implementing this type of conversion over and over again, then I would suggest you take a look at the JavaScript click track library that I released in early December '09, because with this javascript library you could simply add the following code to your page:

clickTrackingLib.addMatches([{
match: clickTrackingLib.getMatchPreset( "all-internal" ),
trackingFunc: function(e, link){
var gwoTracker=_gat._getTracker("UA-XXXXXXX-X");
gwoTracker._trackPageview("/YYYYYYYYYY/goal");
}
}]);
clickTrackingLib.attachTrackingFunctions(null,99);

The above code will tag all non-rel-external links or links with the internal hostname on the page; for just internal hostname links replace "all-internal" with "internal-hostname". I would recommend that you wrap the above into a function though, to be run on the DOM ready event or page loaded event, with jQuery that would look like:

$(document).ready(function(){
clickTrackingLib.addMatches([{
match: clickTrackingLib.getMatchPreset( "all-internal" ),
trackingFunc: function(e, link){
var gwoTracker=_gat._getTracker("UA-XXXXXXX-X");
gwoTracker._trackPageview("/YYYYYYYYYY/goal");
}
}]);
clickTrackingLib.attachTrackingFunctions(null,99);
});

The first line in the code above will setup a function to be executed when the DOM is ready, and all of the page's links have been added. The second line is the first of the function the be executed on DOM ready, and it is adding an array of match objects to the global clickTrackingLib object provided by the click tracking library that I wrote. The following 5 lines define a single match object for the input array, which consists of a preset match function to match internal links (as I said already this preset can be changed, and you can also define a custom match function), and a simple tracking function. When clickTrackingLib.attachTrackingFunctions(null,99); is executed, links are tested against the match functions in the clickTrackingLib object's match object array, and where there is a match the associated trackingFunc function is made in to a onclick event listener for the matched link. As for the two inputs, the null means try all links, and the 99 means use a 99 millisecond delay.

At this point you might be wondering, what if the page has dynamic content, which is changed via ajax, well in that case you can round up the new link(s) in to an array and run the clickTrackingLib.attachTrackingFunctions(links, delay) function again like so:

clickTrackingLib.attachTrackingFunctions(newLinksArray,99);

clickTrackingLib.attachTrackingFunctions(links, delay) will also accept a single link.

A Jetpack: Tweet This!

I wrote my first entry for the Jetpack 50-line Code Challenge a few weeks ago and I would like to share it with you now. The Jetpack is called Tweet This!, and it is meant to help you quickly tweet about a page you are viewing in Firefox with the document's published short url, if it is defined (otherwise tr.im is used).

Tweet This!

Details

The Tweet This! Jetpack adds a 'Tweet This!' menu item to Firefox's 'Bookmarks' menu and context menu, which when used, will allow the user to Tweet about the page they are on. A user can select some text on the page, or else the page's title will be used for some text in the tweet, and then the Jetpack will first check if the text + long url is less than 140 characters long, and just use the long url if so, but otherwise it will use my Get Short URL service (hosted by Google App Engine) to find the shortest url for the page, which is published by the page, and if one has not been published which is smaller than a length you can change in settings, but is by default 35. If the shortest url found is not shorter than the setting length specified then the tr.im service is used to create a short url for the page.

After the Jetpack has a short url for the page, and some text to tweet about it, it will finally trim the text so that the tweet is equal to 140 chars if necessary, then send the tweet, and notify you with the tweet if it has been sent (also the username that it was sent from is displayed).

Notes

  • If you do not see a notification, then an error occurred, and no tweet was sent, so it will be safe to try again, just make sure you wait about a minute before trying again (don't be too hasty). An error would only occur if the Tr.im or Twitter servers return an error.
  • The jetpack settings are pretty basic, and while they provide a range type they do not show the range to the user, or the value the user has selected in the range. Hopefully this will be changed in short time, but until then I'll just let you know here the Max URL Length range is from 20 to 100.

[More]

A Jetpack: Twitter Message Notifier

This is a simple Jetpack Twitter notifier, which checks for new mentions or direct messages for your account and notifies you of them.

The Jetpack loops through tweets to notify you about every 7.5 seconds, until it has no more remaining, then waits 5mins and checks for more DMs or mentions from your Twitter account.

Get it at:

The Daily UserScript: Userscripts.org Improved Pagination

This userscript will improve the pagination at userscripts.org by adding a first and last page link which doesn't make you think.

The Unpleasantry:

My main beef with the current pagination at userscripts.org is that there is no 'First' page and 'Last' page links at either side of the pagination, which is the convention my brain likes. When I'm tired or trying to work very quickly I can assume that this convention is being held by the site I am on.. anyways this leads to me clicking the 'Previous' and 'Next' links when I want 'First' or 'Last' and I always hate when that happens.

The Alleviation:

Once you install the "Userscripts.org Improved Pagination " UserScript will add 'First' and 'Last' links as described above.

The userscript also adds a little more intelligence, such as shortening 'Previous' to 'Prev', collapsing two buttons into one when you are on the first or last page, and uses a "›" for 'Next' to make 'Next ›' and a "»" for 'Last' to make 'Last »' (same idea is applied to 'First' and 'Prev' links as well)

Screen Shot

The Daily UserScript: Remove Top Banner Ad From IMDB

This userscript will remove the top banner ad from imdb.com which makes the entire site more readable and usable.

Even if you use a browser extension such as Adblock Plus, there is a blank space left over which is also distracting, this userscript will take care of that.

The Unpleasantry:

Being forced to see yet another crappy random advertisement on every page of imdb.com right at the top of each page.

The Alleviation:

Once you install the "Remove Top Ad From IMDB" UserScript the top banner advertisement will be removed.

The Daily UserScript: Userscripts.org Remove 'Share' Tab

This userscript removes the 'Share' tab from userscript pages on userscripts.org.

The Unpleasantry:

The 'Share' tab on userscripts just takes to you to addtoany.com which is very annoying; besides that there are two other areas on the page dedicated to 'sharing' and I have a Firefox extension that renders all that sharing junk in to being purely an eyesore.

The Alleviation:

Once you install the "Userscripts.org Remove 'Share' Tab" UserScript the 'Sharing' tab is gone, leaving more room for meaningful tabs such as a 'Versions' tab.

The Daily UserScript: Remove Print CSS (WYSIWYG)

This userscript removes all CSS that is only for media="print", and makes the media="..screen.." into media="...screen..., print" so that what you see on the screen is what you will get for your print out of the page.

The Unpleasantry:

Currently if you print a webpage (or go to print preview) you may notice that most sites do not look the same as they do on the screen when you try to print one of their pages. This is because the page has CSS specifically designated for media="screen" which is different than the CSS they use for media="print".

The Alleviation:

Once you install the "Remove Print CSS (WYSIWYG)" UserScript there will be a Greasemonkey menu command that you can use called 'Remove Print CSS' which removes the media="print" CSS and makes the media="...screen..." CSS media="...screen..., print" CSS, which means that the same CSS used for your screen will be used when you try to print a page.

[More]

The Daily UserScript: UserScript.org Table Row Numbers

This userscript will add row numbers to most tables at userscripts.org.

The Unpleasantry:

Sometimes I want to see the table row numbers displayed, but I currently have to count the figure out what the row numbers are.

The Alleviation:

Once you install the "UserScript.org Table Row Numbers" UserScript the table row numbers will be displayed automatically for most tables.

The Daily UserScript: Sort AMO 'Add to a collection' Menu

This userscript will sort the 'Add to a collection' drop down menu at addons.mozilla.org (AMO) which adds Firefox extensions to collections.

The Unpleasantry:

When you want to add a Firefox extension to a collection at AMO you have to use an unsorted list of the collections that you manage.

The Alleviation:

Once you install the "Sort AMO 'Add to a collection' Menu" UserScript the drop down list of collections you manage is now sorted automatically.

The Daily UserScript: Auto Click UserScript.org's 'Leave!' Group Button

This userscript will automatically click the 'Leave!' button for groups, on the group's join page at userscripts.org.

The Unpleasantry:

Take a look at the current process to leave a group at userscripts.org:

  1. Click the 'leave group?' link.
  2. Click the 'Leave!' button.

The Alleviation:

Once you install the "UserScript.org Auto Click 'Leave!' Button for Groups" UserScript the second step will be automated.

More Entries

© Erik Vold 2007-2010. Contact Erik Vold. Top ^