Skip to content

Commit

Permalink
Set formAction URL to include UTM params if in experiment branch
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxcrawford committed Apr 1, 2020
1 parent b09b9bf commit 63d7557
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions public/js/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,21 @@ function addBentoObserver(){
}
doOauth(e.target, {emailWatch: true});
} else {

const scanFormActionURL = new URL(scanForm.action);


["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content" ].forEach(key => {
if (document.body.dataset[key]) {
scanFormActionURL.searchParams.append(key, document.body.dataset[key]);
}
});

const revisedActionURL = scanFormActionURL.pathname + scanFormActionURL.search;

scanForm.action = revisedActionURL;


if (typeof(ga) !== "undefined") {
ga("send", {
hitType: "event",
Expand Down

0 comments on commit 63d7557

Please sign in to comment.