@xingwangzhe/stalux 1.22.0 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -4,6 +4,14 @@ import { getHeadData } from "@utils/config-utils";
|
|
|
4
4
|
const configEntries = await getCollection("config");
|
|
5
5
|
const headConfig = getHeadData(configEntries);
|
|
6
6
|
const gaID = headConfig?.googleAnalyticsId;
|
|
7
|
+
const gaBootstrap = gaID
|
|
8
|
+
? `window.dataLayer = window.dataLayer || [];
|
|
9
|
+
window.gtag = function gtag() {
|
|
10
|
+
dataLayer.push(arguments);
|
|
11
|
+
};
|
|
12
|
+
gtag("js", new Date());
|
|
13
|
+
gtag("config", ${JSON.stringify(gaID)});`
|
|
14
|
+
: "";
|
|
7
15
|
---
|
|
8
16
|
|
|
9
17
|
{
|
|
@@ -12,26 +20,14 @@ const gaID = headConfig?.googleAnalyticsId;
|
|
|
12
20
|
<script
|
|
13
21
|
type="text/partytown"
|
|
14
22
|
src={`https://www.googletagmanager.com/gtag/js?id=${gaID}`}></script>
|
|
15
|
-
<script
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
window.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
if (!window.__staluxGAConfigured) {
|
|
23
|
-
window.__staluxGAConfigured = true;
|
|
24
|
-
gtag("js", new Date());
|
|
25
|
-
gtag("config", gaID);
|
|
26
|
-
}
|
|
27
|
-
if (!window.__staluxGAListenerAdded) {
|
|
28
|
-
window.__staluxGAListenerAdded = true;
|
|
29
|
-
document.addEventListener("astro:page-load", () => {
|
|
30
|
-
gtag("event", "page_view", {
|
|
31
|
-
page_path: window.location.pathname,
|
|
32
|
-
});
|
|
23
|
+
<script type="text/partytown" set:html={gaBootstrap}></script>
|
|
24
|
+
<script is:inline>
|
|
25
|
+
document.addEventListener("astro:page-load", () => {
|
|
26
|
+
window.dataLayer?.push({
|
|
27
|
+
event: "page_view",
|
|
28
|
+
page_path: window.location.pathname,
|
|
33
29
|
});
|
|
34
|
-
}
|
|
30
|
+
});
|
|
35
31
|
</script>
|
|
36
32
|
</>
|
|
37
33
|
)
|