Skip to content

Commit

Permalink
Bug 1146344. GTM conversion: bug fixes and code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetto committed May 26, 2015
1 parent 0f6ac10 commit 55dabb8
Show file tree
Hide file tree
Showing 41 changed files with 256 additions and 1,357 deletions.
3 changes: 1 addition & 2 deletions .jshintrc-dist
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@

// Custom Globals for bedrock
"globals" : {
"Mozilla" : false,
"gaTrack" : false
"Mozilla" : false
}
}
1 change: 0 additions & 1 deletion bedrock/base/templates/base-resp.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
</head>

<body {% if self.body_id() %}id="{% block body_id %}{% endblock %}" {% endif %}class="html-{{ DIR }} {% block body_class %}{% endblock %}"{% block body_attrs %}{% endblock %}>

<div id="strings"
data-global-close="{{ _('Close') }}"
data-global-next="{{ _('Next') }}"
Expand Down
1 change: 0 additions & 1 deletion bedrock/base/templates/includes/core-dataLayer.html

This file was deleted.

4 changes: 2 additions & 2 deletions bedrock/base/templates/includes/google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

<!-- Google Tag Manager -->
<!-- Customized for Mozilla.org-->
<!-- Region Container: NONE -->
<!-- Rollup Container: System Filtered -->
<!-- Site Container: NONE -->
{% if settings.GTM_CONTAINER_ID %}
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
//core dataLayer object goes here
});
</script>

{% if settings.GTM_CONTAINER_ID %}
<script>
(function(w,d,s,l,i,j,f,dl,k,q){
w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});f=d.getElementsByTagName(s)[0];
Expand Down
4 changes: 1 addition & 3 deletions bedrock/firefox/templates/firefox/nightly_firstrun.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,4 @@ <h3>Learn more about your local Mozilla community</h3>

{% block email_form %}{% endblock %}

{% block js %}
{% javascript 'nightly-firstrun' %}
{% endblock %}
{% block js %}{% endblock %}
2 changes: 1 addition & 1 deletion bedrock/firefox/templates/firefox/sync-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h1>{{ _('Take your Web with you') }}</h1>
{{ _('Download Firefox for Android') }}
</a>
<p class="button-footer">
<a href="https://support.mozilla.org/kb/how-do-i-set-up-firefox-sync" class="ga-link" data-interaction="outbound link click"
<a href="https://support.mozilla.org/kb/how-do-i-set-up-firefox-sync" class="ga-link" data-interaction="outbound link click">
{{ _('Need help?') }}
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,4 @@ <h2>{{ _('Get in Touch') }}</h2>

{% block email_form %}{% endblock %}

{% block js %}
{% javascript 'contribute-studentambassadors-landing' %}
{% endblock %}
{% block js %}{% endblock %}
5 changes: 1 addition & 4 deletions bedrock/settings/local.py-dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ DEBUG = TEMPLATE_DEBUG = DEV = True
#FACEBOOK_PAGE_NAMESPACE = ''
#FACEBOOK_APP_ID = ''

# Google Apps tracking code
GA_ACCOUNT_CODE = ''

# Google Tag Manager ID Example: UA-XXXXX-XX
# Google Tag Manager ID Example: GTM-123456
GTM_CONTAINER_ID = ''

SESSION_COOKIE_SECURE = False
Expand Down
16 changes: 0 additions & 16 deletions bedrock/settings/static_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,12 +981,6 @@
),
'output_filename': 'js/contribute-friends-bundle.js'
},
'contribute-studentambassadors-landing': {
'source_filenames': (
'js/base/social-widgets.js',
),
'output_filename': 'js/contribute-studentambassadors-landing-bundle.js',
},
'contribute-studentambassadors-join': {
'source_filenames': (
'js/mozorg/contribute/contribute-studentambassadors-join.js',
Expand Down Expand Up @@ -1145,7 +1139,6 @@
'source_filenames': (
'js/firefox/australis/australis-uitour.js',
'js/firefox/australis/browser-tour.js',
'js/firefox/australis/fx36/common.js',
'js/firefox/australis/fx36/firstrun.js',
),
'output_filename': 'js/firefox_fx36_firstrun-bundle.js',
Expand All @@ -1154,14 +1147,12 @@
'source_filenames': (
'js/firefox/australis/australis-uitour.js',
'js/firefox/australis/browser-tour.js',
'js/firefox/australis/fx36/common.js',
'js/firefox/australis/fx36/whatsnew.js',
),
'output_filename': 'js/firefox_fx36_whatsnew-bundle.js',
},
'firefox_fx36_whatsnew_no_tour': {
'source_filenames': (
'js/firefox/australis/fx36/common.js',
'js/firefox/australis/fx36/whatsnew-notour.js',
),
'output_filename': 'js/firefox_fx36_whatsnew_no_tour-bundle.js',
Expand Down Expand Up @@ -1300,7 +1291,6 @@
'firefox_feedback': {
'source_filenames': (
'js/base/mozilla-share-cta.js',
'js/firefox/feedback-ga-tracking.js',
),
'output_filename': 'js/firefox_feedback-bundle.js',
},
Expand Down Expand Up @@ -1466,12 +1456,6 @@
),
'output_filename': 'js/mozorg-resp-bundle.js',
},
'nightly-firstrun': {
'source_filenames': (
'js/firefox/firstrun/nightly-firstrun.js',
),
'output_filename': 'js/nightly-firstrun-bundle.js',
},
'partnerships': {
'source_filenames': (
'js/libs/jquery.validate.js',
Expand Down
59 changes: 15 additions & 44 deletions bedrock/tabzilla/templates/tabzilla/tabzilla.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,30 +294,32 @@ var Tabzilla = (function (Tabzilla) {

bar.find('.btn-accept').click(function (event) {
event.preventDefault();
self.trackEvent(self.onaccept.trackAction || 'accept',
self.onaccept.trackLabel,
0, false, // A user interaction event
self.onaccept.callback);

if (self.onaccept.callback) {
self.onaccept.callback();
}

self.hide();
});

bar.find('.btn-cancel').click(function (event) {
event.preventDefault();
self.trackEvent(self.oncancel.trackAction || 'cancel',
self.oncancel.trackLabel,
0, false, // A user interaction event
self.oncancel.callback);

if (self.oncancel.callback) {
self.oncancel.callback();
}

self.hide();
try {
sessionStorage.setItem(self.prefName, 'true');
} catch (ex) {}
});

panel.trigger('infobar-showing');
self.trackEvent(self.onshow.trackAction || 'show',
self.onshow.trackLabel,
0, true, // An auto-triggered, non-interaction event
self.onshow.callback);

if (self.onshow.callback) {
self.onshow.callback();
}

if (opened) {
bar.css('height', 0)
Expand All @@ -341,16 +343,6 @@ var Tabzilla = (function (Tabzilla) {
panel.trigger('infobar-hidden');
});
};
Infobar.prototype.trackEvent = function (action, label, value,
nonInteraction, callback) {
if (typeof(window.gaTrack) !== 'function') {
return;
}

// The 5th value and 6th nonInteraction parameters are optional.
// See the Google Analytics Developer Guide for details:
// https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
};
Infobar.prototype.onshow = {};
Infobar.prototype.onaccept = {};
Infobar.prototype.oncancel = {};
Expand Down Expand Up @@ -534,24 +526,6 @@ var Tabzilla = (function (Tabzilla) {
};
// Expose the object for the tests
Tabzilla.infobar = Infobar;
var setupGATracking = function () {
// track search keywords in GA
$('#tabzilla-search form').on('submit', function (e) {
e.preventDefault();

var $form = $(this);
var keyword = $form.find('#q').val();
var timer = null;
var callback = function () {
clearTimeout(timer);
$form.submit();
};

$form.unbind('submit');

timer = setTimeout(callback, 500);
});
};
var addEaseInOut = function () {
$.extend($.easing, {
'easeInOut': function (x, t, b, c, d) {
Expand Down Expand Up @@ -633,8 +607,6 @@ var Tabzilla = (function (Tabzilla) {
}
});

setupGATracking();

// Careers teaser in error console.
$(window).load(function() {
try {
Expand Down Expand Up @@ -693,7 +665,6 @@ var Tabzilla = (function (Tabzilla) {
+ ' <ul>'
+ ' <li><a href="https://www.mozilla.org/mission/?icn=tabz">{{ _('Mission')|js_escape }}</a></li>'
+ ' <li><a href="https://www.mozilla.org/about/?icn=tabz">{{ _('About')|js_escape }}</a></li>'
+ ' <li><a href="https://www.mozilla.org/projects/?icn=tabz">{{ _('Projects')|js_escape }}</a></li>'
+ ' <li><a href="https://support.mozilla.org/?icn=tabz">{{ _('Support')|js_escape }}</a></li>'
+ ' <li><a href="https://developer.mozilla.org/?icn=tabz">{{ _('Developer Network')|js_escape }}</a></li>'
+ ' </ul>'
Expand All @@ -702,7 +673,7 @@ var Tabzilla = (function (Tabzilla) {
+ ' <li><h2>{{ _('Products')|js_escape }}</h2>'
+ ' <div>'
+ ' <ul>'
+ ' <li><a href="https://www.mozilla.org/firefox/?icn=tabz">Firefox</a></li>'
+ ' <li><a href="https://www.mozilla.org/firefox/products?icn=tabz">Firefox</a></li>'
+ ' <li><a href="https://www.mozilla.org/thunderbird/?icn=tabz">Thunderbird</a></li>'
+ ' <li><a href="https://www.mozilla.org/firefox/os/?icn=tabz">Firefox OS</a></li>'
+ ' </ul>'
Expand Down
44 changes: 1 addition & 43 deletions media/js/base/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function init_android_download_links() {
// language switcher

function init_lang_switcher() {
$('#language').change(function(event) {
$('#language').change(function() {
var language = $(this).val();
$('#lang_form').attr('data-language', language).submit();
});
Expand Down Expand Up @@ -147,45 +147,3 @@ var $strings = $('#strings');
window.trans = function trans(stringId) {
return $strings.data(stringId);
};


function gaTrack(eventArray, callback) {
// submit eventArray to GA and call callback only after tracking has
// been sent, or if sending fails.
//
// callback is optional.
//
// Example usage:
//
// $(function() {
// var handler = function(e) {
// var _this = this;
// e.preventDefault();
// $(_this).off('submit', handler);
// gaTrack(
// ['_trackEvent', 'Newsletter Registration', 'submit', newsletter],
// function() {$(_this).submit();}
// );
// };
// $(thing).on('submit', handler);
// });

var hasCallback = typeof(callback) === 'function';

if (typeof(window._gaq) === 'object') {
// send event to GA
window._gaq.push(eventArray);
// Only set up timer and hitCallback if a callback exists.
if (hasCallback) {
// Need a timeout in order for __utm.gif request to complete in
// order to register the GA event, before excecuting the callback.
setTimeout(callback, 600);
}
} else {
// GA disabled or blocked or something, make sure we still
// call the caller's callback:
if (hasCallback) {
callback();
}
}
}
1 change: 0 additions & 1 deletion media/js/base/social-widgets.js

This file was deleted.

13 changes: 5 additions & 8 deletions media/js/facebookapps/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,11 @@ DOWNLOADTAB.classes.App = (function (singleton) {
self.theater.showScene(2);
}

if (self.window.gaTrack) {

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'virtual-pageview',
virtualUrl: self.virtualUrl
});
}
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'virtual-pageview',
virtualUrl: self.virtualUrl
});

// Delay download so window.location redirect doesn't interrupt
// rendering and to give Google Analytics time to track
Expand Down
18 changes: 3 additions & 15 deletions media/js/firefox/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,33 +275,21 @@
}
}

var trackClick = function (gaObj, event) {
window.dataLayer = window.dataLayer || [];
if (event.metaKey || event.ctrlKey) {
// Open link in new tab
window.dataLayer.push(gaObj);
} else {
event.preventDefault();
gaObj.eventCallback = function() { window.location = event.target.href;};
window.dataLayer.push(gaObj);
}
};

// track link on the primary CTA
$('#intro .dl-button').attr({
'data-interaction': 'download click',
'data-interaction': 'download click',
'data-download-version': 'Firefox for Android'
});

// track link on the secondary CTA
$('#subscribe-download-wrapper .dl-button').attr({
'data-interaction': 'button download click',
'data-interaction': 'button download click',
'data-download-version': 'Firefox for Android'
});

// track links except the accordion
$('#privacy, #sync, #subscribe-download-wrapper ul').attr({
'data-interaction': 'link click',
'data-interaction': 'link click',
'data-download-version': 'href'
});

Expand Down
Loading

0 comments on commit 55dabb8

Please sign in to comment.