/ Published in: JavaScript

<p>usage:
<code><a href="" onclick="recordOutboundLink(link, category, action, opt_label, opt_value);return false;">
<form id="uniqueID" onsubmit="trackFormSubmit(form, category, action, opt_label, opt_value);return false;"></code></p>
<code><a href="" onclick="recordOutboundLink(link, category, action, opt_label, opt_value);return false;">
<form id="uniqueID" onsubmit="trackFormSubmit(form, category, action, opt_label, opt_value);return false;"></code></p>
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var arrTracker = ['trackerName1', 'trackerName2']; // tracker names // tracking form submit function trackFormSubmit(form, category, action, opt_label, opt_value) { for (var i = 0, ii = arrTracker.length; i < ii; i++) { _gat._getTrackerByName(arrTracker[i])._trackEvent(category, action, opt_label, opt_value); } setTimeout("document.getElementById('"+form.id+"').submit();", 100); return false; } // tracking link click function recordOutboundLink(link, category, action, opt_label, opt_value) { for (var i = 0, ii = arrTracker.length; i < ii; i++) { _gat._getTrackerByName(arrTracker[i])._trackEvent(category, action, opt_label, opt_value); } setTimeout('document.location = "' + link.href + '"', 100); return false; } <a href="" onclick="recordOutboundLink(link, category, action, opt_label, opt_value);return false;"> <form id="uniqueID" onsubmit="trackFormSubmit(form, category, action, opt_label, opt_value);return false;">
Comments
