Skip to content

Commit faf1867

Browse files
committed
feat: add event dataLayer
1 parent 11ddb09 commit faf1867

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/cookie-consent.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ function addScripts(lvl) {
1111

1212
// Necessary
1313
if (lvl.includes(COOKIE_CONSENT_NECESSARY)) {
14+
if (!window.digitalData) {
15+
window.digitalData = {};
16+
}
17+
18+
if (!window.dataLayer) {
19+
window.dataLayer = [];
20+
}
21+
22+
const dataLayerInfo = {
23+
event: "ab-viewed",
24+
experiment: "OKTA_NEW_HOMEPAGE_v1",
25+
variation: "control"
26+
};
27+
28+
//add the data to each data layer object
29+
window.digitalData.abInfo = dataLayerInfo;
30+
window.dataLayer.push(dataLayerInfo);
1431
// GTM
1532
(function(w, d, s, l, i) {
1633
w[l] = w[l] || [];
@@ -62,4 +79,4 @@ const poll = window.setInterval(() => {
6279
} else {
6380
tries++;
6481
}
65-
}, POLL_INTERVAL);
82+
}, POLL_INTERVAL);

0 commit comments

Comments
 (0)