Skip to content

Commit

Permalink
Bug 821016: Fix download click tracking for GA.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmac committed Dec 21, 2012
1 parent 080b3cb commit 1e4e8d6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
6 changes: 4 additions & 2 deletions apps/firefox/templates/firefox/new-b.html
@@ -1,4 +1,4 @@
{% extends "/firefox/base-resp.html" %}
{% extends "firefox/base-resp.html" %}

{% block page_title %}Free Download{% endblock %}
{% block body_id %}firefox-new{% endblock %}
Expand All @@ -8,6 +8,8 @@
<h2><a href="{{ url('mozorg.home') }}"><img src="/media/img/firefox/new/header-firefox.png" alt="{{_('Firefox for desktop')}}" /></a></h2>
{% endblock %}

{% block webtrends %}{% endblock %}

{% block site_css %}
{{ css('firefox_new_test') }}
{% endblock %}
Expand Down Expand Up @@ -106,4 +108,4 @@ <h1 class="large">{{_('Different <span>by design</span>')}}</h1>

{% block js %}
{{ js('firefox_new') }}
{% endblock %}
{% endblock %}
14 changes: 11 additions & 3 deletions media/js/firefox/new.js
Expand Up @@ -28,13 +28,15 @@
var $scene2 = $('#scene2');
var $stage = $('#stage-firefox');
var $thankYou = $('.thankyou');
$('.download-firefox').on('click', function() {
$('.download-firefox').on('click', function(e) {
// cancel natural event
e.preventDefault();

// track download click
if (_gaq) {
_gaq.push(['_trackPageview',
'/en-US/products/download.html?referrer=new-b']);
}

if (!Modernizr.csstransitions) {
$scene2.css('visibility', 'visible');
$stage.animate({
Expand All @@ -51,6 +53,12 @@
$thankYou.focus();
}, 500);
}

// delay natural event
var that = this;
setTimeout(function() {
window.location.href = $(that).attr('href');
}, 300);
});
});
})(window.jQuery, window.Modernizr, window._gaq, window.site);
})(window.jQuery, window.Modernizr, window._gaq, window.site);
10 changes: 7 additions & 3 deletions media/js/global.js
Expand Up @@ -5,6 +5,10 @@

// download buttons

if (typeof(dcsMultiTrack) === 'undefined') {
dcsMultiTrack = function(){};
}

/**
* A special function for IE. Without this hack there is no prompt to download after they click. sigh.
* bug 393263
Expand Down Expand Up @@ -70,14 +74,14 @@ $(document).ready(function() {
function getFirefoxMasterVersion()
{
var version = 0;

var matches = /Firefox\/([0-9]+).[0-9]+(?:.[0-9]+)?/.exec(
navigator.userAgent
);

if (matches !== null && matches.length > 0) {
version = parseInt(matches[1], 10);
}

return version;
}

0 comments on commit 1e4e8d6

Please sign in to comment.