generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
/
head.html
64 lines (58 loc) · 2.02 KB
/
head.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="/aemeds/scripts/aem.js" type="module"></script>
<script src="/aemeds/scripts/scripts.js" type="module"></script>
<link rel="stylesheet" href="/aemeds/styles/styles.css" />
<link rel="dns-prefetch" href="https://www.servicenow.com/" />
<!-- To eliminate flicker introduced by Adobe Target-->
<style id="at-body-style">body {opacity: 1}</style>
<script>
async function loadScript(src, attrs) {
return new Promise((resolve, reject) => {
if (!document.querySelector(`head > script[src="${src}"]`)) {
const script = document.createElement("script");
script.src = src;
if (attrs) {
// eslint-disable-next-line no-restricted-syntax, guard-for-in
for (const attr in attrs) {
script.setAttribute(attr, attrs[attr]);
}
}
script.onload = resolve;
script.onerror = reject;
document.head.append(script);
} else {
resolve();
}
});
}
async function loadAdobeDTM() {
const prod =
"https://assets.adobedtm.com/a441b904b50e/7a4facbbcffb/launch-039be8795dc8.min.js";
const stage =
"https://assets.adobedtm.com/a441b904b50e/7a4facbbcffb/launch-a2ae4c3b0523-staging.min.js";
const searchParams = new URLSearchParams(window.location.search);
if (window.location.pathname === '/blogs/2023/ai-business-process-analyst-role'
&& searchParams.get("disableLaunch") === "true") {
return;
}
const env = searchParams.get("launch");
if (env === "prod") {
loadScript(prod, { async: "" });
return;
}
if (env === "stage") {
loadScript(stage, { async: "" });
return;
}
const { host } = window.location;
if (host === "servicenow.com" || host === "www.servicenow.com") {
loadScript(prod, { async: "" });
} else {
if (searchParams.get("disableLaunch") === "true") {
return;
}
loadScript(stage, { async: "" });
}
}
loadAdobeDTM();
</script>