Skip to content

Commit

Permalink
Updated UTMs to set properly
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxcrawford committed Apr 1, 2020
1 parent 7a3b6fe commit f654c59
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
31 changes: 12 additions & 19 deletions public/js/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,30 +252,13 @@ function addBentoObserver(){

function buildExperimentUtms(checked) {

const experimentBranch = document.body.dataset.experiment;
let fxaOptAnswer = "opt_out";
if (checked) {
fxaOptAnswer = "opt_in";
}

// fx-monitor-alert-me-blue-btn
const entrypoint = "fx-monitor-alert-me-blue-link";
const entrypoint_experiment = "growthuserflow1";
const entrypoint_variation = experimentBranch;
const utm_source = document.body.dataset.utm_source;
const utm_campaign = "growthuserflow1";
const utm_content = fxaOptAnswer;
const utm_term = experimentBranch;
const form_type = "email";
return {
entrypoint_variation,
entrypoint_experiment,
utm_source,
utm_campaign,
utm_content,
utm_term,
form_type,
};
document.body.dataset.utm_content = fxaOptAnswer;
}

( async() => {
Expand Down Expand Up @@ -401,13 +384,23 @@ function buildExperimentUtms(checked) {


if (document.body.dataset.experiment) {

const submitBtn = document.querySelector("#scan-user-email input[type='submit']");
const createFxaCheckbox = document.getElementById("createFxaCheckbox");

createFxaCheckbox.addEventListener("change", (e)=> {
document.body.dataset.utm_content = "opt_out";
if (event.target.checked) {
document.body.dataset.utm_content = "opt_in";
}
});

submitBtn.addEventListener("click", (e)=> {
document.body.dataset.utm_content = "opt_out";
if (createFxaCheckbox.checked) {
e.preventDefault();
const utms = buildExperimentUtms(createFxaCheckbox.checked);
document.body.dataset.utm_content = "opt_in";
// const utms = buildExperimentUtms(createFxaCheckbox.checked);
// console.log(utms);
if (typeof(ga) !== "undefined") {
ga("send", "event", "" , "Click", "");
Expand Down
2 changes: 1 addition & 1 deletion views/layouts/default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<link rel="icon" href="/img/favicons/favicon-128.png" sizes="128x128" />
<link rel="icon" href="/img/favicons/favicon-256.png" sizes="256x256" />
</head>
<body {{> analytics/default_dataset }} {{#if experimentBranch }} data-experiment="{{experimentBranch}}" {{/if}} data-bento-app-id="fx-monitor">
<body {{> analytics/default_dataset }} {{#if experimentBranch }} {{> analytics/experiment }} data-experiment="{{experimentBranch}}" {{/if}} data-bento-app-id="fx-monitor">
{{> header/header }}
{{{ body }}}
{{> footer }}
Expand Down
4 changes: 2 additions & 2 deletions views/partials/analytics/default_dataset.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ data-logos-origin="{{ LOGOS_ORIGIN }}"
data-fxa-enabled="fxa-enabled"
data-fxa-address={{ getFxaUrl }}
data-utm_source="{{ SERVER_URL }}"
data-utm_campaign="growthuserflow1"
data-utm_campaign="fx-monitor-fxa-integration"

{{#if req.session.user}}
data-signed-in-user="true"
{{else}}
Expand Down
4 changes: 4 additions & 0 deletions views/partials/analytics/experiment.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data-utm_campaign = "growthuserflow1";
data-utm_content = "";
data-utm_term = {{experimentBranch}}
data-form_type = "email";

0 comments on commit f654c59

Please sign in to comment.