Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[fix bug 1127120] Add GA events for download/update buttons
  • Loading branch information
Cory Price committed Jan 29, 2015
1 parent a3b0bdd commit d87c554
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions media/js/firefox/hello/index.js
Expand Up @@ -85,6 +85,21 @@
$('#try-hello-footer').css('display', 'block');
};

var addLinkEvent = function (linkSelector, eventName) {
$(linkSelector).on('click', function(e) {
var newTab = (this.target === '_blank' || e.metaKey || e.ctrlKey);
var href = this.href;
if (newTab) {
w.gaTrack(['_trackEvent', '/hello interactions', 'productPage', eventName]);
} else {
e.preventDefault();
w.gaTrack(['_trackEvent', '/hello interactions', 'productPage', eventName], function() {
w.location = href;
});
}
});
};

if (w.isFirefox()) {
// if Fx, hide all footer messaging
// (correct messaging to display determined below)
Expand Down Expand Up @@ -140,32 +155,24 @@
} else {
// if Hello is not in toolbar/menu, change footer button to link
// to a SUMO article and do some GA tracking
$('#try-hello-footer').on('click', function(e) {
var newTab = (this.target === '_blank' || e.metaKey || e.ctrlKey);
var href = this.href;

if (newTab) {
w.gaTrack(['_trackEvent', '/hello interactions', 'productPage', 'IneligibleClick']);
} else {
e.preventDefault();
w.gaTrack(['_trackEvent', '/hello interactions', 'productPage', 'IneligibleClick'], function() {
w.location = href;
});
}
});
addLinkEvent('#try-hello-footer', 'IneligibleClick');

w.gaTrack(['_trackEvent', '/hello interactions', 'productPage', 'IneligibleView']);
}
});
} else {
// if Fx is version 34 or lower (no Hello support) display update messaging in footer
$('#ctacopy-oldfx').show();

addLinkEvent('.download-link', 'ClickUpgrade');
}
} else {
// for non-Fx users, show get Fx feature & remove node to maintain nth-child margin rules
// (we wont need this node/copy for non-Fx users)
$('#feature-account').remove();
$('#feature-getfx').show();

addLinkEvent('.download-link', 'ClickDownload');
}

$videoLink.on('click', function(e) {
Expand Down

0 comments on commit d87c554

Please sign in to comment.