Created
November 15, 2010 20:41
-
-
Save pavenuto/700901 to your computer and use it in GitHub Desktop.
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
if ($('#no-results').length) { | |
var term = $('#search-results').find('li:first a.only-this-tag').text(); | |
if ($("#search-results").find('li').length == 1) { | |
$.track('ProductSearch', 'ZeroResults', term); | |
} | |
} | |
if ($("#zip-code-search").length) { | |
$("#zip-code-search").bind("submit", function(e) { | |
var zipcode = $('#zip_code').val(); | |
$.track('Locations','ZipCodeSearch',zipcode,{pause: true}); | |
}); | |
} | |
$("a[rel=external]").attr("target", "_blank").bind("click.external", function (b) { | |
$.track("External Links", "click", this.href, {pause: true}); | |
}); | |
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
$.extend({ | |
trace: function(msg){ | |
if (window.console) { | |
console.log(msg); | |
}; | |
}, | |
track: function(category, action, label, options){ | |
var settings = { pause: false }; | |
if (options) $.extend(settings, options); | |
try { | |
_gaq.push(['_trackEvent', category, action, (label ? label : 'blank')]); | |
} catch(e) {} | |
$.trace('_gaq.push([\'_trackEvent\', ' + category + ', ' + action + ', ' + label + ')]);'); | |
if (settings.pause) { | |
// pause to allow google script to run | |
var date = new Date(); | |
var curDate = null; | |
do { | |
curDate = new Date(); | |
} while(curDate-date < 300); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment