Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation AB Test #237

Merged
merged 3 commits into from
Feb 13, 2017
Merged

Navigation AB Test #237

merged 3 commits into from
Feb 13, 2017

Conversation

alecgibson
Copy link
Contributor

Add functionality to check for A/B Testing, and display content according to which "bucket" the user has been added to.

This WIP PR adds a helper method to the controller to check for A/B bucket (with associated tests).

As a proof-of-concept, it also updates two of the content_item views to show either an A or B view. Currently the only difference between the two is the display of "normal" breadcrumbs (view A) or "taxon" breadcrumbs (view B).

If we continue in this style, we should add A/B views for all Content Items. Is this the best approach? If so, should we be grouping them in subfolders under content_items to reduce clutter? Is there any scope for commonising, or is that a waste of time, given that - if testing is successful - we'd just want to delete all the "A" views anyway in the long run.

@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 24, 2017 17:28 Inactive
@NickColley
Copy link
Contributor

If we're only testing the breadcrumbs wouldnt only want to A/B that component itself?

@alecgibson
Copy link
Contributor Author

@NickColley we'll eventually be shuffling actual HTML around. For example, in Detailed Guide, we'll need to make space on the right-hand-side for a Related Links box.

@carvil
Copy link
Contributor

carvil commented Jan 24, 2017

We will also be removing "Part of" as well, so this will be a bit more comprehensive than just breadcrumbs.

with_locale do
render content_item_template
end
end

def should_present_b_view?
(ab_testing_group == "B") && new_navigation_enabled? && content_is_tagged_to_a_taxon?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have the new chrome extension ready so we can add ourselves to the B group in the A/B test on integration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. @suzannehamilton ? At the moment you can manually manipulate your own headers with a Chrome extension.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's currently on master, we'll release soon.

@alecgibson
Copy link
Contributor Author

Yes, this is just a small change to start with to keep the PR manageable and get early feedback.

(ab_testing_group == "B") && new_navigation_enabled? && content_is_tagged_to_a_taxon?
end

helper_method :should_present_b_view?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of changing this to should_present_new_content_view? It could be hard to understand what the B version is without more context.

@@ -0,0 +1,9 @@
<%= content_for :title, "#{@content_item.page_title} - #{t("content_item.format.#{@content_item.document_type}", count: 1)}" %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the comment above, I think we could try to rename these partials to something other than a/b, so it's clearer what they render. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you propose? Is "New"/"Old" any better than "A"/"B"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of:

_case_study.html.erb

for the A version and:

_case_study_for_new_navigation.html.erb

for the B version?

@@ -56,4 +63,16 @@ def error_403(exception)
def error_notfound
render plain: 'Not found', status: :not_found
end

def ab_testing_group
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the logic for generic A/B testing be collected in a separate file?
Can we have a further separate place for the logic specific to each test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do, although we'd still need a method here to check if the content is tagged to a taxon. Where's the best place for such a method to live?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be included as a module.

ENV['ENABLE_NEW_NAVIGATION'] == 'yes'
end

def content_is_tagged_to_a_taxon?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a taxon?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a new document type that defines the new navigation structure. A taxonomy is a tree of taxons. Content is tagged to these taxon nodes essentially as leaf nodes.

@@ -31,6 +29,22 @@ def content_id
content_item.parsed_content["content_id"]
end

def taxons
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breadcrumbs aren't included on every format.
We use a mixin pattern to include features when they're needed.
Should these methods be in a mixin and included on just the formats that need them?

This will prevent the single content_item_presenter from getting too large.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure sounds good to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: #238

@@ -0,0 +1,54 @@
<%= content_for :title, @content_item.page_title %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what the differences between a.html.erb and b.html.erb are. Rather than two templates, could the variations be provided by picking different partials? This reduces duplication and makes the template variations clearer.

Copy link
Contributor

@fofr fofr Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg

if should_present_b_view?
render "shared/taxon_breadcrumbs
else:
render "shared/breadcrumbs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not dived into it yet, but I think the HTML is going to be moving around. For example, on Detailed Guides, we need to shift the content to the left two thirds to make room for a Related Items box on the right. This would include shifting the contents and some metadata out of the way (presumably to the top of the document?). I'm not sure that just picking different partials will really cut it in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or the logic could be in the partial itself, if it affects all breadcrumbs on all formats with breadcrumbs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for not putting the switch in the partial itself is that I didn't want two levels of switching - it's clear coming to Detailed Guide that there's a big switch on the template. It'd be less clear if you came to a single Detailed Guide that the partials have switches buried in them, making it harder still to track down differences between views.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To someone editing a detailed guide or case study, it is not clear that they need to make the change in two places.

Why does it need to be clear that there is a big switch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this way you're making it explicit by saying "This is what the old content looks like", and "This is what the new content looks like."

Copy link
Contributor

@fofr fofr Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what the differences between a.html.erb and b.html.erb are.

I think this needs to be solved, whichever approach is taken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fofr I'm not sure I understand what you're proposing. Surely the only way to be able to have arbitrarily different HTML views is to have two different templates (or variants)?

@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 11:23 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 11:34 Inactive
@tijmenb
Copy link
Contributor

tijmenb commented Jan 25, 2017

Just remembered that Rails has a "variant" feature. Would that work for us here?

http://edgeguides.rubyonrails.org/4_1_release_notes.html#action-pack-variants

@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 13:06 Inactive
@@ -75,6 +75,43 @@ class ContentItemsControllerTest < ActionController::TestCase
assert_response :forbidden
end

test "honours AB Testing cookie" do
assert_equal "yes", ENV['ENABLE_NEW_NAVIGATION']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the testing of the AB feature be more generic, ie not be tied to this specific test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you propose?

Copy link
Contributor

@fofr fofr Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mock the environment variable and mock the headers?

Then add tests specific to this AB test as well as the generic ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what good generic tests would be? The checks for AB testing aren't (and don't need to be?) generic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just your test that needs re-phrasing then, "honours AB Testing cookie" sounds generic.

@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 14:47 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 15:00 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 15:05 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 15:12 Inactive
@NickColley
Copy link
Contributor

Variants looking good! 👍 Tiny typo case_stude -> case_study

@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 15:20 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 15:31 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 January 25, 2017 16:46 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 February 9, 2017 17:26 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 February 9, 2017 17:34 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 February 10, 2017 12:06 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 February 10, 2017 12:13 Inactive
@alecgibson alecgibson changed the title [Do not merge] Navigation AB Test Navigation AB Test Feb 10, 2017
@alecgibson
Copy link
Contributor Author

@carvil this is finally ready for re-review (cc @mobaig )

Copy link
Contributor

@carvil carvil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@malcolmbaig
Copy link
Contributor

LG 👍

@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 February 13, 2017 10:09 Inactive
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-237 February 13, 2017 10:27 Inactive
@alecgibson
Copy link
Contributor Author

@carvil I've now bumped the versions of both govuk_navigation_helpers and govuk_ab_testing

@carvil
Copy link
Contributor

carvil commented Feb 13, 2017

@alecgibson could you please git cherry-pick b7f62d3 to this PR? That way we can ship everything in one go.

@alecgibson
Copy link
Contributor Author

@carvil done

@carvil carvil merged commit 3f1780d into master Feb 13, 2017
@carvil carvil deleted the navigation-ab-test branch February 13, 2017 11:43
@tijmenb
Copy link
Contributor

tijmenb commented Feb 13, 2017

🎈

@NickColley
Copy link
Contributor

🎉

@alecgibson
Copy link
Contributor Author

Belatedly adding this Trello card for future context: https://trello.com/c/yLGE64pa/1013-changes-to-education-related-content-pages-as-part-of-the-new-navigation-in-government-frontend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants