Skip to content

Instantly share code, notes, and snippets.

@perifer
Created January 24, 2012 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perifer/1668761 to your computer and use it in GitHub Desktop.
Save perifer/1668761 to your computer and use it in GitHub Desktop.
Track events on external pages - asynchronous Google Analytics
(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