Created
January 24, 2012 07:59
-
-
Save perifer/1668761 to your computer and use it in GitHub Desktop.
Track events on external pages - asynchronous Google Analytics
This file contains 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
(function($) { | |
var passThrough = false; | |
var track = function(el, action) { | |
_gaq.push(["_trackEvent", "Connect/Log in", action]); | |
passThrough = true; | |
_gaq.push(function() { | |
$(el).trigger("click"); | |
}); | |
} | |
$("#edit-oauthconnector-twitter").click( | |
function() { | |
if (!passThrough) { | |
track(this, "Twitter"); | |
return false; | |
} | |
} | |
); | |
$("#edit-oauthconnector-linkedin").click( | |
function() { | |
if (!passThrough) { | |
track(this, "LinkedIn"); | |
return false; | |
} | |
} | |
); | |
$("#facebook_login_custom a").click( | |
function(e) { | |
if (!passThrough) { | |
track(this, "Facebook"); | |
} | |
else { | |
window.location.href = this.href; | |
} | |
return false; | |
} | |
); | |
$("#login-block .form-submit").click( | |
function() { | |
if (!passThrough) { | |
track(this, "Drupal Log in"); | |
return false; | |
} | |
} | |
); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment