@xingwangzhe/stalux 1.22.3 → 1.22.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingwangzhe/stalux",
3
- "version": "1.22.3",
3
+ "version": "1.22.5",
4
4
  "description": "A powerful, modern Astro blog theme — use as template or install as plugin",
5
5
  "keywords": [
6
6
  "astro",
@@ -8,7 +8,8 @@ const gaBootstrap = gaID
8
8
  ? `window.dataLayer = window.dataLayer || [];
9
9
  window.gtag = function gtag() { dataLayer.push(arguments); };
10
10
  gtag("js", new Date());
11
- gtag("config", ${JSON.stringify(gaID)}, { allow_google_signals: false });`
11
+ gtag("config", ${JSON.stringify(gaID)}, { send_page_view: false });
12
+ gtag("event", "page_view", { page_title: document.title, page_location: location.href });`
12
13
  : "";
13
14
  ---
14
15
 
@@ -20,11 +21,13 @@ gtag("config", ${JSON.stringify(gaID)}, { allow_google_signals: false });`
20
21
  src={`https://www.googletagmanager.com/gtag/js?id=${gaID}`}></script>
21
22
  <script type="text/partytown" set:html={gaBootstrap}></script>
22
23
  <script is:inline>
24
+ let lastPath = window.location.pathname;
23
25
  document.addEventListener("astro:page-load", () => {
24
- window.dataLayer?.push({
25
- event: "page_view",
26
- page_path: window.location.pathname,
27
- });
26
+ const path = window.location.pathname;
27
+ if (path !== lastPath) {
28
+ lastPath = path;
29
+ window.gtag?.("event", "page_view", { page_path: path });
30
+ }
28
31
  });
29
32
  </script>
30
33
  </>