-
Notifications
You must be signed in to change notification settings - Fork 198
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
Exp 2 Analytics Fix #1672
Exp 2 Analytics Fix #1672
Conversation
7d70e84
to
42244e1
Compare
…removed/excluded from the experiment.
const mozlog = require("../log"); | ||
const log = mozlog("controllers.utils"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added debug logging. Information should show up in terminal when running locally.
@@ -33,39 +35,57 @@ function hasUserSignedUpForRelay(user) { | |||
|
|||
function getExperimentBranch(req, sorterNum) { | |||
|
|||
if (req.session.excludeFromExperiment && !req.query.experimentBranch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the primary fix for #1671. In summary, any time a session would return false
for getExperimentBranch()
, it would be forgotten when the function was called again (on another page load, refresh, etc). This applies specifically to a use who would be eligible to be in the experiment. They would have the experiment sorter run until it landed them in one of the experiment branches.
One note about this if statement is that it includes an override for a query parameter. This is for testing purposes. If you add ?experimentBranch=vb
, it will place you in that cohort, regardless of getting discounted previously. One caveat is that if your language settings rule you out, this query request is denied (Again – for testing purposes).
return false; | ||
} | ||
log.debug("This session has been set to the requested branch: ", req.query.experimentBranch); | ||
req.session.excludeFromExperiment = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this session variable is only set during return false
occasions, this reset here was necessary.
@@ -126,7 +126,6 @@ function sendRecommendationPings(ctaSelector) { | |||
hitCallback: function() { | |||
removeUtmsFromUrl(); | |||
}, | |||
nonInteraction: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the Growth team was having issues tracking the experiment in GA, we want to minimize changes at this time. I propose we re-open #1643 to track that issue in the future.
@@ -62,6 +62,16 @@ function doOauth(el) { | |||
url.searchParams.append(key, document.body.dataset[key]); | |||
} | |||
}); | |||
|
|||
if (typeof(ga) !== "undefined") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added back this event to mirror what was fired in the first experiment.
@@ -1,3 +1,3 @@ | |||
data-utm_term={{experimentBranch}} | |||
data-experiment={{experimentBranch}} | |||
data-utm_campaign="growthuserflow2" | |||
data-utm_campaign="growthuserflow3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revised this ID for a clean break in the data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep and append to growthuserflow2
, e.g. growthuserflow2a
so we can keep them sequentially in sync with our project docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spot-checks look good. I disabled the experiment, ran thru scans, sign-up, and sign-ins. Enabled the experiment, ran thru scans, sign-up, and sign-ins. Re-disabled the experiment, and ran thru scans, sign-up, and sign-ins. All work.
Comments here are questions/comments - not requests for changes.
req.session.experimentBranch = experimentBranch; | ||
req.session.excludeFromExperiment = excludeFromExperiment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting. Does req.session.reset
not do this implicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My in-code comment is a little murky. We want to make sure that any user assigned to a specific experiment (including being excluded) is remembered past the session reset.
The req.session.reset
removes both of these variables.
public/js/fxa-analytics.js
Outdated
@@ -120,13 +120,15 @@ function sendRecommendationPings(ctaSelector) { | |||
// If an experiment is active, set the "Growth Experiment Version" | |||
// Custom Dimension to whichever branch is active. | |||
ga("set", "dimension7", `${document.body.dataset.experiment}`); | |||
ga("set", "dimension8", `${document.body.dataset.experiment}`); | |||
ga("set", "campaignName", `${document.body.dataset.utm_campaign}`); | |||
ga("set", "campaignTerm", `${document.body.dataset.utm_term}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a campaignTerm
in the Analytics.js field reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. Fixing this – that property doesn't exist. I was following naming conventions (and that property is the one that contains the experiment branch name). Looks like I need to set it to campaignKeyword.
/cc @zerokarmaleft
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, campaignKeyword
is the right choice for utm_term
let experimentNumber = 0; | ||
let experimentBranch = getExperimentBranch(mockRequest, experimentNumber); | ||
expect(experimentBranch).toBe("va"); | ||
|
||
mockRequestSessionReset(mockRequest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes my no-mutable-state spidey-sense tingle, but if you're confident in the test logic here it's okay with me. Potential bugs in test code aren't as bad as potential bugs in functional code, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy that. I did a session earlier this week with @gregtatum and we talked about resetting the request/env between each test. This function is a compromise – the extra step (that I did not opt for) is to break this test out at each expect
to ensure it's a clean start every time.
No description provided.