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

Exp 2 Analytics Fix #1672

Merged
merged 11 commits into from
Apr 30, 2020
Merged

Exp 2 Analytics Fix #1672

merged 11 commits into from
Apr 30, 2020

Conversation

maxxcrawford
Copy link
Contributor

No description provided.

@lesleyjanenorton lesleyjanenorton temporarily deployed to monitor-v2 April 29, 2020 16:29 Inactive
@groovecoder groovecoder temporarily deployed to monitor-v2 April 29, 2020 16:51 Inactive
@groovecoder groovecoder temporarily deployed to monitor-v2 April 29, 2020 17:56 Inactive
@groovecoder groovecoder temporarily deployed to monitor-v2 April 29, 2020 20:46 Inactive
@groovecoder groovecoder temporarily deployed to monitor-v2 April 29, 2020 20:53 Inactive
@groovecoder groovecoder temporarily deployed to monitor-v2 April 29, 2020 20:54 Inactive
@groovecoder groovecoder temporarily deployed to monitor-v2 April 29, 2020 22:05 Inactive
@groovecoder groovecoder temporarily deployed to monitor-v2 April 30, 2020 02:14 Inactive
Comment on lines +5 to +6
const mozlog = require("../log");
const log = mozlog("controllers.utils");
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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;
Copy link
Contributor Author

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.

@groovecoder groovecoder temporarily deployed to monitor-v2 April 30, 2020 02:29 Inactive
@@ -126,7 +126,6 @@ function sendRecommendationPings(ctaSelector) {
hitCallback: function() {
removeUtmsFromUrl();
},
nonInteraction: true,
Copy link
Contributor Author

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") {
Copy link
Contributor Author

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"
Copy link
Contributor Author

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

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?

@groovecoder groovecoder temporarily deployed to monitor-v2 April 30, 2020 03:20 Inactive
@maxxcrawford maxxcrawford marked this pull request as ready for review April 30, 2020 03:20
Copy link
Member

@groovecoder groovecoder left a 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;
Copy link
Member

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?

Copy link
Contributor Author

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.

@@ -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}`);
Copy link
Member

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?

Copy link
Contributor Author

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

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);
Copy link
Member

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.

Copy link
Contributor Author

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.

@groovecoder groovecoder temporarily deployed to monitor-v2 April 30, 2020 15:31 Inactive
@groovecoder groovecoder temporarily deployed to monitor-v2 April 30, 2020 16:23 Inactive
@maxxcrawford maxxcrawford merged commit 8920513 into master Apr 30, 2020
@maxxcrawford maxxcrawford deleted the 1671-exp-2-analytics-fix branch July 13, 2020 03:29
@maxxcrawford maxxcrawford added the growth-team Growth team label Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
growth-team Growth team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants