Skip to content

Commit 30ecebf

Browse files
Remove Donation Flow 2023 AB Test. (Fixes #408) (#409)
- Clean up some now unneeded code - Comment out the rest that may be useful later - Enable redirect to downloads page after download has begun - Move FRU specific donation url generation to our build process (Python) - Removed JavaScript from start page for now
1 parent 32e8492 commit 30ecebf

12 files changed

Lines changed: 85 additions & 173 deletions

File tree

assets/js/common/ab-testing.js

Lines changed: 12 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ if (typeof Mozilla === 'undefined') {
88

99
/**
1010
* Super simple ABTest module, it puts you in one of the buckets.
11-
* Bucket === 0 - FundraiseUp
12-
* Bucket === 1 - give.thunderbird.net
11+
* Bucket === 0 - A
12+
* Bucket === 1 - B
1313
*/
1414
const ABTest = {};
1515
ABTest.bucket = null;
@@ -23,18 +23,21 @@ if (typeof Mozilla === 'undefined') {
2323
* Once a bucket has been chosen, this function does nothing.
2424
*/
2525
ABTest.Choose = function() {
26+
/*
2627
if (ABTest.bucket !== null) {
2728
return;
2829
}
2930
3031
ABTest.bucket = ABTest.RandomInt(0, 1);
32+
*/
3133
}
3234

3335
/**
3436
* Tracks our bucket choice.
3537
* Called from matomo.js, registers a bucket if no bucket has been chosen.
3638
*/
3739
ABTest.Track = function() {
40+
/*
3841
if (ABTest.bucket === null) {
3942
ABTest.Choose();
4043
}
@@ -43,75 +46,33 @@ if (typeof Mozilla === 'undefined') {
4346
const _paq = window._paq = window._paq || [];
4447
4548
// TrackEvent: Category, Action, Name
46-
_paq.push(['trackEvent', 'AB-Test - Donation Flow 2023', 'Bucket Registration', ABTest.bucket === 0 ? 'fru' : 'give']);
49+
_paq.push(['trackEvent', 'AB-Test - Test Name Here', 'Bucket Registration', ABTest.bucket === 0 ? 'a' : 'b']);
50+
*/
4751
}
4852

4953
/**
5054
* Are we in the FundraiseUp bucket?
5155
* @returns {boolean}
5256
*/
53-
ABTest.IsInFundraiseUpBucket = function() {
57+
ABTest.IsInBucketA = function() {
5458
return ABTest.bucket === 0;
5559
}
5660

5761
/**
5862
* Are we in the legacy give.thunderbird.net bucket?
5963
* @returns {boolean}
6064
*/
61-
ABTest.IsInGiveBucket = function() {
65+
ABTest.IsInBucketB = function() {
6266
return ABTest.bucket === 1;
6367
}
6468

65-
/**
66-
* FundraiseUp's download functionality. This will simply raise the Donation form.
67-
* @param download_url
68-
* @private
69-
* @deprecated Might be removed in a later release
70-
*/
71-
ABTest._FundraiseUpDownload = function(download_url) {
72-
window.Mozilla.Donation.DisplayDownloadForm(download_url);
73-
}
74-
75-
/**
76-
* Legacy give.thunderbird.net download functionality.
77-
* This will redirect them to the donation url, which will start the download.
78-
* @param download_url
79-
* @param donate_url
80-
* @private
81-
*/
82-
ABTest._GiveDownload = function(download_url, donate_url) {
83-
// Don't redirect if we're on the failed download page.
84-
if ($("body").attr('id') !== 'thunderbird-download') {
85-
// MSIE and Edge cancel the download prompt on redirect, so just leave them out.
86-
if (!(/msie\s|trident\/|edge\//i.test(navigator.userAgent))) {
87-
setTimeout(function() {
88-
window.location.href = donate_url;
89-
}, 5000);
90-
}
91-
}
92-
window.Mozilla.Utils.triggerIEDownload(download_url);
93-
}
94-
95-
/**
96-
* Start the Download, it will handle determining what bucket we're in and what download path we need to go down.
97-
* @param event : Event
98-
*/
99-
ABTest.Download = function(event) {
100-
const element = event.target;
101-
const download_url = element.href;
102-
const donate_url = element.dataset.donateLink || null;
103-
104-
if (ABTest.IsInGiveBucket()) {
105-
ABTest._GiveDownload(download_url, donate_url);
106-
}
107-
}
108-
10969
/**
11070
* Replaces a 'HTMLAnchorElement' href tag with the bucket's (only FRU right now) equivalent url.
11171
* @param element : HTMLAnchorElement
11272
*/
11373
ABTest.ReplaceDonateLinks = function(element) {
114-
if (ABTest.IsInFundraiseUpBucket()) {
74+
/*
75+
if (ABTest.IsInBucketA()) {
11576
// If we somehow don't have an element, we can exit and still start any redirects.
11677
if (!element) {
11778
return;
@@ -126,6 +87,7 @@ if (typeof Mozilla === 'undefined') {
12687
12788
element.href = window.Mozilla.Donation.MakeDonateUrl(utmContent, utmSource, utmMedium, utmCampaign, redirect);
12889
}
90+
*/
12991
}
13092

13193
/**
@@ -135,27 +97,6 @@ if (typeof Mozilla === 'undefined') {
13597
ABTest.Init = function() {
13698
// Pick one!
13799
ABTest.Choose();
138-
139-
// Replace the donation button's links with the correct one.
140-
const donate_buttons = document.querySelectorAll('[data-donate-btn]');
141-
for (const donate_button of donate_buttons) {
142-
ABTest.ReplaceDonateLinks(donate_button);
143-
}
144-
145-
// Replace the download button's links with our download redirect
146-
// But only do that if we're not already on the download page
147-
if (window.location.href.indexOf('/download/') === -1) {
148-
const download_buttons = document.querySelectorAll('.download-link');
149-
for (const download_button of download_buttons) {
150-
ABTest.ReplaceDonateLinks(download_button);
151-
152-
// If we're in FRU bucket, don't trigger download events for our non-download page buttons
153-
// Otherwise we'll be getting download==thunderbird.net instead of download==download.mozilla.org
154-
if (ABTest.IsInFundraiseUpBucket()) {
155-
download_button.className = download_button.className.replace('matomo-track-download', '');
156-
}
157-
}
158-
}
159100
}
160101

161102
window.Mozilla.ABTest = ABTest;

assets/js/common/donations.js

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ if (typeof Mozilla === 'undefined') {
77
'use strict';
88

99
var Donation = {};
10-
Donation.ANIMATION_DURATION = 250;
11-
Donation.WINDOW_POS_KEY = '_tb_donation_position';
1210
Donation.NEWSLETTER_URL = `/${window.siteLocale}/newsletter`;
1311
/**
1412
* Is the download form visible?
@@ -48,8 +46,6 @@ if (typeof Mozilla === 'undefined') {
4846
// Retrieve the current download link before we close the form (as that clears it)
4947
const download_link = Donation.CurrentDownloadLink;
5048

51-
Donation.CloseForm();
52-
5349
// No download link? Exit.
5450
if (!download_link) {
5551
return;
@@ -103,8 +99,10 @@ if (typeof Mozilla === 'undefined') {
10399
* @param utmMedium {?string}
104100
* @param utmCampaign {?string}
105101
* @param redirect {?string} - Whether we should redirect the user to another page
102+
* @deprecated Donation url code has been migrated to static build process. This is left here in case of further AB tests.
106103
*/
107-
Donation.MakeDonateUrl = function(utmContent = null, utmSource = 'thunderbird.net', utmMedium = 'fru', utmCampaign = 'donation_flow_2023', redirect = null) {
104+
Donation.MakeDonateUrl = function(utmContent = null, utmSource = 'thunderbird.net', utmMedium = 'fru', utmCampaign = 'donation_2023', redirect = null) {
105+
/*
108106
const is_donate_redirect = redirect === 'donate';
109107
const is_download_redirect = redirect && redirect.indexOf('download-') !== -1;
110108
@@ -137,76 +135,9 @@ if (typeof Mozilla === 'undefined') {
137135
}
138136
139137
return query_params;
138+
*/
140139
}
141140

142-
/**
143-
* Close the donation form
144-
* This will clear any currently set download link.
145-
*/
146-
Donation.CloseForm = function() {
147-
$('#amount-modal').fadeOut(Donation.ANIMATION_DURATION);
148-
$('#modal-overlay').fadeOut(Donation.ANIMATION_DURATION);
149-
$(document.body).removeClass('overflow-hidden');
150-
Donation.IsVisible = false;
151-
Donation.CurrentDownloadLink = null;
152-
}
153-
154-
/**
155-
* Display the donation download modal for fundraise up
156-
* @param download_url - Link to the actual file download
157-
*/
158-
Donation.DisplayDownloadForm = function(download_url) {
159-
// Show the donation form.
160-
$('#amount-modal').fadeIn(Donation.ANIMATION_DURATION);
161-
$('#modal-overlay').fadeIn(Donation.ANIMATION_DURATION);
162-
$(document.body).addClass('overflow-hidden');
163-
Donation.IsVisible = true;
164-
Donation.CurrentDownloadLink = download_url;
165-
166-
// Set the "No thanks, just download" button's link
167-
if ($("#amount-cancel")[0]) {
168-
$("#amount-cancel")[0].href = download_url;
169-
}
170-
171-
// Define cancel and close button on the donation form.
172-
$('#amount-cancel').click(function(e) {
173-
// No prevent default
174-
Donation.CloseForm();
175-
});
176-
$('#close-modal').click(function(e) {
177-
e.preventDefault();
178-
Donation.CloseForm();
179-
});
180-
181-
// Close modal when clicking the overlay
182-
$('#modal-overlay').click(function(e) {
183-
e.preventDefault();
184-
Donation.CloseForm();
185-
});
186-
187-
// Close modal when pressing escaoe
188-
$(document).keyup(function(e) {
189-
if (e.key === "Escape") {
190-
Donation.CloseForm();
191-
}
192-
});
193-
194-
// Define active amount in amount selection.
195-
$('#amount-selection > label').click(function() {
196-
$('#amount-selection > label.active').removeClass('active');
197-
$(this).addClass('active');
198-
});
199-
$('#amount-other-selection').click(function() {
200-
$('#amount-other').focus();
201-
});
202-
$('#amount-other').click(function() {
203-
$('#amount-other-selection').prop('checked', true);
204-
});
205-
$('#amount-other').on('input', function() {
206-
$('#amount-other-selection').val($(this).val());
207-
});
208-
};
209-
210141
window.Mozilla.Donation = Donation;
211142
Donation.Init();
212143
})();

assets/js/common/mozilla-utils.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,34 @@ if (typeof Mozilla === 'undefined') {
3838
}
3939
};
4040

41+
/**
42+
* Redirects the user to a donation url. This should be triggered after a download.
43+
* @param {HTMLAnchorElement} element
44+
*/
45+
Utils.redirectAfterDownload = function(element) {
46+
const download_url = element.href;
47+
const donate_url = element.getAttribute('data-donate-link') || null;
48+
49+
// Don't redirect if we're on the failed download page.
50+
if ($("body").attr('id') !== 'thunderbird-download') {
51+
// MSIE and Edge cancel the download prompt on redirect, so just leave them out.
52+
if (!(/msie\s|trident\/|edge\//i.test(navigator.userAgent))) {
53+
setTimeout(function() {
54+
window.location.href = donate_url;
55+
}, 5000);
56+
}
57+
}
58+
window.Mozilla.Utils.triggerIEDownload(download_url);
59+
}
60+
4161
// attach an event to all the download buttons to trigger the special
4262
// ie functionality if on ie
4363
Utils.initDownloadLinks = function() {
4464
$('#submit-button').hide();
4565
$('.download-link').each(function() {
4666
var $el = $(this);
4767
$el.click(function(e) {
48-
window.Mozilla.ABTest.Download(e);
68+
Utils.redirectAfterDownload(e.currentTarget);
4969
});
5070
});
5171
$('.download-list').attr('role', 'presentation');

build-site.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
if args.startpage:
2929
print('Rendering start page ' + langmsg)
30-
site = builder.Site(languages, settings.START_PATH, settings.START_RENDERPATH, settings.START_CSS, js_bundles=settings.START_JS, debug=args.debug)
30+
site = builder.Site(languages, settings.START_PATH, settings.START_RENDERPATH, settings.START_CSS, debug=args.debug)
3131
site.build_startpage()
3232
else:
3333
print('Rendering www.thunderbird.net ' + langmsg)

helper.py

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from __future__ import unicode_literals
22

33
import inspect
4+
import urllib
5+
46
import jinja2
57
import json
68
import markdown
@@ -318,19 +320,43 @@ def thunderbird_url(page, channel='None'):
318320

319321

320322
@jinja2.contextfunction
321-
def donate_url(ctx, content='', source='thunderbird.net', medium='give', campaign='donation_flow_2023', download=False):
322-
# If this link is from a download button, donate.mozilla.org has thank you text.
323-
download_string = ''
324-
if download:
325-
download_string = '&tbdownload=true'
326-
327-
# Add utm_campaign if we are using it.
328-
campaign_string = ''
329-
if campaign:
330-
campaign_string = '&utm_campaign={0}'.format(campaign)
331-
332-
return (settings.DONATE_LINK.format(content=content, source=source, medium=medium)
333-
+ campaign_string + download_string)
323+
def donate_url(ctx, content='', source='thunderbird.net', medium='fru', campaign='donation_2023', show_donation_modal=True, download=None, download_channel=None):
324+
"""Forms a donation url with the given parameters. If you pass in None for any of the fields they will be excluded from the url
325+
:param content: UTM Content tag
326+
:param source: UTM Source tag
327+
:param medium: UTM Medium tag
328+
:param campaign: UTM Campaign tag
329+
:param show_donation_modal: Whether we want to append form=support that will automatically load the FRU modal
330+
:param download: Whether we have already downloaded Thunderbird (Download button specific.) Boolean or None.
331+
:param download_channel: What download channel to append to the url (Download button specific.) String or None.
332+
"""
333+
form = None
334+
if show_donation_modal:
335+
form = 'support'
336+
337+
query = {
338+
'form': form,
339+
'utm_content': content,
340+
'utm_source': source,
341+
'utm_medium': medium,
342+
'utm_campaign': campaign,
343+
'downloaded': download,
344+
'download_channel': download_channel
345+
}
346+
347+
filtered_query = {k: v for k, v in query.items() if v is not None}
348+
349+
return "?{}".format(urllib.urlencode(filtered_query))
350+
351+
352+
@jinja2.contextfunction
353+
def redirect_donate_url(ctx, location='thunderbird.download', make_full_url=False, **kwargs):
354+
"""Helper function to piece together the full donation url. Defaults to the settings for our Download button."""
355+
base_url = ''
356+
if make_full_url:
357+
base_url = settings.CANONICAL_URL
358+
359+
return "{url}{path}{query}".format(url=base_url, path=url(ctx, location), query=donate_url(ctx, **kwargs))
334360

335361

336362
def safe_markdown(text):

settings.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
'thunderbird.donate.faq': '/donate#faq',
135135
'thunderbird.donate.ways-to-give': '/donate#ways-to-give',
136136
'thunderbird.donate.ways-to-give.check': '/donate#ways-to-give-check',
137+
'thunderbird.download': '/download',
137138
'thunderbird.download-beta': '/download/beta',
138139
'thunderbird.enterprise': 'https://wiki.mozilla.org/Thunderbird/tb-enterprise',
139140
'thunderbird.enterprise.documentation': 'https://enterprise.thunderbird.net/',
@@ -157,11 +158,6 @@
157158
'thunderbird.organizations',
158159
]
159160

160-
DONATE_LINK = (
161-
'https://give.thunderbird.net/'
162-
'?utm_source={source}&utm_medium={medium}&utm_content={content}'
163-
)
164-
165161
# WEBSITE_CSS = {
166162
# 'calendar-bundle': ['less/thunderbird/calendar.less', 'less/base/menu-resp.less'],
167163
# 'responsive-bundle': ['less/sandstone/sandstone-resp.less', 'less/base/global-nav.less'],

start-page/_base-resp.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@
1818
<main>
1919
{% block main %}{% endblock %}
2020
</main>
21-
<script type="text/javascript" src="/media/js/common-bundle.js" charset="utf-8"></script>
2221
</body>
2322
</html>

0 commit comments

Comments
 (0)