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

Pass Traffic Cop custom referrer to attribution scripts (Fixes #13593) #13621

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

alexgibson
Copy link
Member

@alexgibson alexgibson commented Aug 30, 2023

One-line summary

This PR fixes some existing holes in attribution data, where referrer was being lost when Traffic Cop performs a redirect.

Significant changes and points to review

I added a global Mozilla.Analytics.getReferrer() helper that other scripts can use to get referrer more reliably. It touches three places:

  • Glean
  • Stub Attribution
  • FxA Attribution

Hopefully the tests I added can give some confidence that the value is now being passed as expected, but I also added some manual testing instructions below.

Issue / Bugzilla link

#13593

Testing

Note: test all the items below using a browser with DNT disabled.

Glean

  1. Set GLEAN_LOG_PINGS=True in your .env.
  2. Open http://localhost:8000/en-US/firefox/new/
  3. Click on the Mozilla logo in the main navigation to go to the home page. You should be entered into a traffic cop experiment with wither ?v=1 or ?v=2 in the URL.
  4. Confirm in the page ping in the web console that referrer is http://localhost:8000/en-US/firefox/new/ and not http://localhost:8000/en-US/

Stub attribution

  1. Open http://localhost:8000/en-US/firefox/new/
  2. Click on the Mozilla logo in the main navigation to go to the home page. You should be entered into a traffic cop experiment with wither ?v=1 or ?v=2 in the URL.
  3. In the web console, run Mozilla.StubAttribution.getAttributionData().
  4. Confirm that referrer is http://localhost:8000/en-US/firefox/new/ and not http://localhost:8000/en-US/.

FxA Attribution

I found this add-on useful for manual testing. With it you can override the referrer to any value you choose:

image

  1. With a modified referrer set to https://www.google.com/, open http://localhost:8000/en-US/products/vpn/. You should be redirected into a traffic cop experiment with entrypoint_experiment=vpn-refresh-pricing in the URL
  2. Scroll down to the pricing section and inspect a subscription link in dev tools.
  3. Verify the link contains utm_source=google&utm_medium=organic

@alexgibson alexgibson force-pushed the glean-referrer branch 2 times, most recently from b6541b2 to 6d58275 Compare August 30, 2023 14:04
@alexgibson alexgibson added P2 Second level priority - Should have Needs Review Awaiting code review Review: XS Code review time: up to 30min labels Aug 31, 2023
@alexgibson alexgibson marked this pull request as ready for review August 31, 2023 08:40
@craigcook craigcook self-assigned this Sep 7, 2023
Copy link
Member

@craigcook craigcook left a comment

Choose a reason for hiding this comment

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

Tested and works as expected 🪅

@craigcook craigcook merged commit f2575ea into mozilla:main Sep 11, 2023
5 checks passed
@alexgibson alexgibson deleted the glean-referrer branch September 11, 2023 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review Awaiting code review P2 Second level priority - Should have Review: XS Code review time: up to 30min
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants