From 706063c2cafba42b384da7242153a0d818722642 Mon Sep 17 00:00:00 2001 From: Maxx Crawford Date: Mon, 27 Apr 2020 12:32:51 -0500 Subject: [PATCH] Restricted growth experiment pings to only apply to users inside the experiment. (treatment and control) --- public/js/fxa-analytics.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/public/js/fxa-analytics.js b/public/js/fxa-analytics.js index f1090a2e465..b8cf772508b 100644 --- a/public/js/fxa-analytics.js +++ b/public/js/fxa-analytics.js @@ -209,14 +209,16 @@ function sendRecommendationPings(ctaSelector) { }); }); - document.querySelectorAll(".ga-growth-ping").forEach((el) => { - el.addEventListener("click", async(e) => { - // Overwrite current event category for active OAuth buttons - if (el.dataset.eventCategory !== "fxa-oauth") { - el.dataset.eventCategory = "fxa-oauth"; - } - await sendPing(el, "Click", el.dataset.eventLabel); + if (document.body.dataset.experiment) { + document.querySelectorAll(".ga-growth-ping").forEach((el) => { + el.addEventListener("click", async(e) => { + // Overwrite current event category for active OAuth buttons + if (el.dataset.eventCategory !== "fxa-oauth") { + el.dataset.eventCategory = "fxa-oauth"; + } + await sendPing(el, "Click", el.dataset.eventLabel); + }); }); - }); + } } })();