Created
May 30, 2012 08:41
-
-
Save catchamonkey/2834596 to your computer and use it in GitHub Desktop.
Infinity Tracking - Custom Trigger for all mailto links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Registers a click handler for all mailto links on the page and fires | |
* an Infinity Tracking custom trigger when clicked | |
* We use 'live' for mailto links loaded after the DOM is ready | |
* @author Chris Sedlmayr <[email protected]> | |
*/ | |
// copy of initialise the infinity var | |
var _ictt = _ictt || []; | |
$(document).ready(function() { | |
// find 'a' elements that have an href starting with mailto: | |
$('a[href^="mailto:"]').live('click', function() { | |
// ensure the infinity variable is available | |
if (typeof _ictt != 'undefined') { | |
// track this, using the mailto location as the title | |
_ictt.push([ | |
'_customTrigger', | |
'MAILTOCLICK', | |
{ | |
't':this.href.replace(/^mailto\:/i, '') | |
} | |
]); | |
}; | |
}); | |
}); |
Nice one, that was next up. Cheers.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And in native JS: