Skip to content

Commit

Permalink
GROWENG-3818 changing legacy google analytics event to datalayer push (
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlokajtar committed Jun 18, 2024
1 parent 0277528 commit 9ce39d3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 63 deletions.
48 changes: 20 additions & 28 deletions static/js/src/dynamic-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
// Open the contact us modal
function open() {
updateHash(triggeringHash);
ga(
"send",
"event",
"interactive-forms",
"open",
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "open",
path: window.location.pathname,
});
}

// Removes the triggering hash
Expand Down Expand Up @@ -243,13 +241,11 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
if (button.classList.contains("pagination__link--previous")) {
index = index - 1;
setState(index);
ga(
"send",
"event",
"interactive-forms",
"goto:" + index,
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "goto:" + index,
path: window.location.pathname,
});
} else {
var valid = true;

Expand All @@ -262,13 +258,11 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
if (valid) {
index = index + 1;
setState(index);
ga(
"send",
"event",
"interactive-forms",
"goto:" + index,
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "goto:" + index,
path: window.location.pathname,
});
}
}
});
Expand Down Expand Up @@ -346,13 +340,11 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
formContainer.removeChild(contactModal);
modalTrigger.focus();
updateHash("");
ga(
"send",
"event",
"interactive-forms",
"close",
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "close",
path: window.location.pathname,
});
}

// Update the content of the modal based on the current index
Expand Down
60 changes: 25 additions & 35 deletions static/js/src/kernel-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,11 @@
// Open the contact us modal
function open() {
updateHash(triggeringHash);
ga(
"send",
"event",
"interactive-forms",
"open",
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "open",
path: window.location.pathname,
});
}

// Removes the triggering hash
Expand Down Expand Up @@ -195,13 +193,11 @@

if (submitButton) {
submitButton.addEventListener("click", function () {
ga(
"send",
"event",
"interactive-forms",
"submitted",
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "submitted",
path: window.location.pathname,
});
});
}

Expand Down Expand Up @@ -236,13 +232,11 @@
if (button.classList.contains("pagination__link--previous")) {
index = index - 1;
setState(index);
ga(
"send",
"event",
"interactive-forms",
"goto:" + index,
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "goto:" + index,
path: window.location.pathname,
});
} else {
var valid = true;

Expand All @@ -255,13 +249,11 @@
if (valid) {
index = index + 1;
setState(index);
ga(
"send",
"event",
"interactive-forms",
"goto:" + index,
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "goto:" + index,
path: window.location.pathname,
});
}
}
});
Expand Down Expand Up @@ -337,13 +329,11 @@
formContainer.classList.add("u-hide");
formContainer.removeChild(contactModal);
updateHash("");
ga(
"send",
"event",
"interactive-forms",
"close",
window.location.pathname
);
dataLayer.push({
event: "interactive-forms",
action: "close",
path: window.location.pathname,
});
}

// Update the content of the modal based on the current index
Expand Down

0 comments on commit 9ce39d3

Please sign in to comment.