Skip to content

Commit 7aa3d8b

Browse files
Implement a first experiment
This sets up a simple UI experiment, defining an alternative set of styles for the search form. The search form starts in the _form.html.erb partial, with most users getting a "standard" class - the experimental group would get the "alt" class, which is rendered differently. The experiment ends when a user reaches a search results page (i.e, they submitted the form and thus got results). Curious folks can force themselves into one or the other pool by using a querystring such as ?ab_test[ui_colors]=alt or ?ab_test[ui_colors]=standard
1 parent ce683e2 commit 7aa3d8b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

app/assets/stylesheets/partials/_search.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,17 @@
5959

6060
/* basic search bar */
6161
.search-form {
62-
background-color: #989898;
6362
margin-bottom: 0rem;
6463
padding: 2.4rem 2rem 1.6rem 2rem;
6564

65+
&.standard {
66+
background-color: #989898;
67+
}
68+
69+
&.alt {
70+
background-color: #ffd700;
71+
}
72+
6673
details {
6774
&:first-of-type {
6875
margin-top: 1rem;

app/controllers/search_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ class SearchController < ApplicationController
1010
before_action :validate_geodistance_units!, only: %i[results]
1111

1212
def results
13+
# if we are loading results, the user submitted the form - so this experiment is finished
14+
ab_finished(:ui_colors)
15+
16+
# ab_test(:result_format)
17+
1318
# inject session preference for boolean type if it is present
1419
params[:booleanType] = cookies[:boolean_type] || 'AND'
1520

app/views/search/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<form id="search-form" action="<%= results_path %>" method="get" role="search">
1+
<form id="search-form" class="<%= ab_test(:ui_colors, "standard", "alt") %>" action="<%= results_path %>" method="get" role="search">
22
<h3>What can we help you find?</h3>
33
<div class="form-wrapper">
44
<input id="basic-search-main" type="search" class="field field-text basic-search-input" name="q" title="Keyword anywhere" placeholder="Search for anything" value="<%= params[:q] %>" required>

0 commit comments

Comments
 (0)