Click Tracking JavaScript Library Now Available

Purpose

To help web publishers easily track link clicks the correct way, across browser platforms, with tools like Google Analytics (GA) and Google Website Optimizer (GWO).

Typically a web publisher will want to do something like track all external links on a website with GA, setup a GWO test where the conversion is a click through, or do both on the same page for a few pages of their site. This javascript library was designed to make tasks such as these simple.

About

clickTrackingLib

Adding the click-tracking-lib.js or the click-tracking-lib-with-presets.js to a web page provides you with a clickTrackingLib javascript object. Once you provide clickTrackingLib with some match objects, you can then have clickTrackingLib scan a single, set, or all document links to determine if the link(s) should have tracking functions applied to it or not, and do so if needed. If one or more tracking functions are applied to a link, then a delay function will be applied to the link (this can be disabled too of course, and the delay can user defined but the default is 99 ms).

The Delay Function

The delay function is meant to delay the user from being redirected to a new page for just a bit to allow time for say a Google Analytics image request to complete, and avoid being canceled by the user's browser. It can be disabled, but it is added by with a 99 sec delay by default, which can be customized, as the very last onClick event listener, after all of the desired provided Match object trackingFunc's are applied.

The delay function technically only sets a timeout to redirect the user after x ms, but in order for the delay to work the link's default functionality, namely redirecting the user, needs to be disabled, if the link doesn't just open in a new tab (target="_blank" and target="_new" are checked for). To disable the default functionality the link's onclick attribute must be set to onclick="return false;" which I figured should be fine because all well made websites won't use that attribute except to make it equal to "return false;" anyhow. If your site is not well made, then you should think about fixing it or having it fixed for you, but you can still use this library by simply not using the delay function and implementing it by some other means.

Presets

There are a number of presets available if you use click-tracking-lib-with-presets.js or click-tracking-presets.js; presets are predefined match functions for common use cases, such as matching all internal links, or external links, or download links. They can be used as they written, you could cut out the ones you won't use, or simply use them as examples when you define your own custom match objects.

The can be accessed from the clickTrackingLib.getMatchPreset( name ) method. The possible name values and the meanings behind them are as follows:

  • 'rel-external': matches rel-external links
  • 'external-hostname': matches external hostname links
  • 'all-external': matches all rel-external and external hostname links
  • 'filetypes': matches file names: (docx*|xlsx*|pptx*|exe|zip|pdf|xpi|rar|xls)
  • 'non-rel-external': matches non-rel-external links
  • 'internal-hostname': matches internal hostname links
  • 'all-internal': matches non-rel-external links or internal hostname links

Match Objects

Any object that has a 'match(link):boolean' method and 'trackingFunc(event,link):void' method defined.

match(link):boolean

This method will take a link element as input, run some test on it and return true or false, if true is returned then the Match object's trackingFunc will be added to the link.

trackingFunc(event,link):void

This method will be provided with two input values; event is the click event object, and link is a reference to the link element. You can obtain a reference to this from the event object, but there is some cross browser logic you would need to implement, so I thought a direct reference to the link would be handy. The function should not return anything.

new clickTrackingLib._clickTrackingLib();

If you want to create multiple clickTrackingLib objects, that contain different sets of match object arrays, then you need to create a new one, like so:

var myNewClickTrackingObj = new clickTrackingLib._clickTrackingLib();

This will give you a new object, myNewClickTrackingObj, which is like clickTrackingLib in all but two ways. First myNewClickTrackingObj will not have a _clickTrackingLib() method, and second it will not have a getMatchPreset() method, even if clickTrackingLib.getMatchPreset() was defined. This is because you don't need a bunch of objects in memory with those two methods, only one, which is the singleton clickTrackingLib object.

How To Use

  1. Download either click-tracking-lib-with-presets.js or click-tracking-lib.js (see ABOUT fore more information) from the project repository at GitHub.
  2. Minify it with one of the following options:
  3. Upload the minified script to your site.
  4. Add <script src=".." type="text/javascript"></script> for the script to the desired pages.
  5. Write some code:
    • define some match objects (just an object with a match method and trackingFunc method)
    • Add match objects to your clickTrackingLib object
    • Call the clickTrackingLib.attachTrackingFunctions( links, delay ) when desired.
      • links: can be a single anchor element, an array of anchor elements, or falsely so that the default is used, which is document.links.
      • delay: should be a positive integer or falsey, in the latter case no delay function will be added to the links scanned, in the former case a delay function will be applied with the specified delay value.

[More]

How To Remove the Windows XP Language Bar

I just want to briefly point out how to disable the Windows XP language bar from reappearing after every system restart, because it was bothering me for a long time. For some reason I assumed I would not be able to fix this for no good reason, and the pain wasn't so bad that I cared enough about it, but today I decided to look up how to do this and it was quite simple to do once the steps were laid out, so I wanted to pass this information along in case it helps someone else.

  1. Click Start, select Control Panel, and then select Regional and Language Options.
  2. On the Languages tab, under Text services and input languages, click Details.
  3. Under Preferences, click Language Bar.
  4. Uncheck the Show the Language bar on the desktop check box.
  5. Press OK and the Language Bar will be gone

Disconnected: No Supported authentication methods available

I recently ran in to this error message when trying to pull or push anything from/to GitHub with TortoiseGit and PuTTY: "Disconnected: No Supported authentication methods available".

It turns out this message was a result of my lack of knowledge of PuTTY, and I simply did not have Pageant running with the ssh key for GitHub loaded.

I did some searching on Google and there wasn't much help out there that I could find, so I wanted to explain this for the next guy and make a reference to the only page that helped me, which was at GitHub: Guides: Addressing authentication problems with SSH

Greasemonkey Command With Input String For Ubiquity 0.5

I have been working hard on this for the last week, trying to get a better version out by getting an update I did for Greasemonkey into the trunk (this will take a lot of time, and will be an improvement), but I am now pleased to release a version of the Greasemonkey Ubiquity Command (ready for Ubiquity 0.5) which will accept an input string.

What is it?

It is a Ubiquity command which allows you find and execute Greasemonkey menu commands.

How do you get it?

  1. Get Ubiquity 0.5 or greater.
  2. Get Greasemonkey.
  3. Get the Greasemonkey Ubiquity Command.
  4. Get a UserScript with a menu command, and that is it!

[More]

How To Setup Windows XP With Boot Camp On A Macbook

I finally setup Windows XP Pro on my Macbook using Boot Camp over the weekend, and I hit some gotchas, because I did not read the guide. So I thought I would make a quick summary of the process. Although, I would recommend reading the installation guide to anyone doing this for the first time.

Setting up Windows XP on a Macbook with Boot Camp:

  1. Run Boot Camp Assistant.
  2. Create a partition for Windows (you will need at least 6 GB, I prefer around 20 GB).
  3. Insert Windows XP Installation CD when it is requested, Boot Camp will restart the system and start the Windows installation process.
  4. Follow the Windows installation instructions until you are asked to selected a partition.
  5. Select the C:\BOOTCAMP partition.
  6. Select "Format the partition using the FAT file system (Quick)". Do not select "Leave the current file system intact".
  7. Continue following the Windows installation instructions until it has completed.
  8. Insert your Mac OS X Installation DVD. If the installer does not start automatically, then run the setup.exe on the disc.
  9. Follow the Boot Camp + Drivers installation instructions until the setup is complete.
  10. Go to Start → All Programs → Apple Software Update, and run this to install the Multi-Touch Trackpad Update for Windows XP & Vista, which is very important.
  11. Update Windows and your done.

Note: To manually select the Operating System that you want to use during startup, press and hold the "option" key after you hear the chime during the boot cycle.

How To Setup Linklint In Cygwin For Windows

Here is a short guide on how to setup Linklint windows machine using cygwin.

Setup Instructions:

  1. Install Cygwin, and make sure that you install the perl package.
  2. Create a folder for Linklint (mine is c:/apps/linklint/).
  3. Download Linklint.
  4. Extract the archive of Linklint to the folder you created in step 2.
  5. Open Cygwin, and move to the folder you created in step 2.
  6. run "$ perl linklint-x-x-x" (this will bring up some instructions & options)

How To Install Cygwin For Windows

This is just some very breif instructions on how to install cygwin for windows.

For those of you that do not already know, cygwin is a linux-like environment for windows

  1. Create a folder c:\cygwin
  2. Download cygwin's setup.exe from http://www.cygwin.com/ and save setup.exe in c:\cygwin
  3. Click Start...Run...and type c:\cygwin\setup.exe
  4. When it asks for "Local Package Directory", type c:\cygwin
  5. When a selection screen comes up, you can resize the window to see better, click the little "View" button for "Full" view, then find and select the packages you wish to use.
  6. Click next to start installing cygwin.
© Erik Vold 2007-2010. Contact Erik Vold. Top ^