Skip to content

Commit

Permalink
[bug 846756] Add A/B test for product ordering on /products
Browse files Browse the repository at this point in the history
?b returns the first two products in reverse order.
  • Loading branch information
rlr committed Mar 12, 2013
1 parent 1e20f1e commit 19ad392
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
18 changes: 18 additions & 0 deletions apps/products/templates/products/products.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
{% set crumbs = [(None, title)] %}
{% set styles = ('products',) %}

{% block top_of_head %}
{# Temporary A/B test for bug 846756 #}
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
k='65912487-18',d=document,l=d.location,c=d.cookie;
if(l.search.indexOf('utm_expid='+k)>0)return;
function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.
indexOf(';',i);return escape(c.substring(i+n.length+1,j<0?c.
length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write(
'<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':
'://www')+'.google-analytics.com/ga_exp.js?'+'utmxkey='+k+
'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().
valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"><\/sc'+'ript>')})();
</script><script>utmx('url','A/B');</script>
<!-- End of Google Analytics Content Experiment code -->
{% endblock %}

{% block content %}
<section id="products-and-services" class="grid_12">
<h1>{{ title }}</h1>
Expand Down
8 changes: 7 additions & 1 deletion apps/products/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
@mobile_template('products/{mobile/}products.html')
def product_list(request, template):
"""The product picker page."""
products = Product.objects.filter(visible=True)
products = list(Product.objects.filter(visible=True))

# A/B test for Bug 846756:
if 'b' in request.GET:
# Flip the first two products
products[0], products[1] = products[1], products[0]

return jingo.render(request, template, {
'products': products})

Expand Down
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<!DOCTYPE html>
<html class="no-js" lang="{{ request.LANGUAGE_CODE }}" {% if DIR %}dir="{{ DIR }}"{% endif %}>
<head>
{% block top_of_head %}{% endblock %}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{% block title %}{% if title %}{{ title }} | {% endif %}{{ _('Mozilla Support', 'site_title') }}{% endblock %}</title>

Expand Down

0 comments on commit 19ad392

Please sign in to comment.