From ac9e10b436cfcc694c67029dc3c771422fd4e141 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Thu, 19 Mar 2026 13:56:18 +0100 Subject: [PATCH 1/2] fix: auto-detect domain from hostname for zero-config GTM support When data-domain attribute and pulseConfig are both unavailable (common with GTM which strips data-* attributes), the script now falls back to location.hostname. This is safe because the backend already validates Origin/Referer against the registered domain. Strips www. prefix on auto-detected hostname to match typical Pulse registration patterns. --- public/script.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 1a15f6d..12c076d 100644 --- a/public/script.js +++ b/public/script.js @@ -40,7 +40,10 @@ return (script && script.hasAttribute('data-' + name)) || globalConfig[name] === true || globalConfig[camel] === true; } - const domain = attr('domain'); + // * Resolve domain: explicit config > data-domain > auto-detect from hostname + // * Auto-detect enables zero-config GTM installs; the backend validates Origin anyway + var explicitDomain = attr('domain'); + const domain = explicitDomain || location.hostname.replace(/^www\./, ''); if (!domain) { return; } From e6d840abb9e9367120749dc64c57d12f151d4321 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Thu, 19 Mar 2026 13:58:09 +0100 Subject: [PATCH 2/2] docs: simplify GTM integration guide for auto-detect domain --- lib/integration-guides.tsx | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/integration-guides.tsx b/lib/integration-guides.tsx index dd175f7..b8bfa83 100644 --- a/lib/integration-guides.tsx +++ b/lib/integration-guides.tsx @@ -2298,31 +2298,30 @@ export default defineConfig({

Follow these steps to add Pulse through GTM:

  1. Go to Tags → New → Custom HTML
  2. -
  3. Paste the snippet below (replace your-site.com with your domain)
  4. +
  5. Paste the snippet below
  6. Set the trigger to All Pages
  7. Publish your container
- {` -`} + {``}

- This uses a global config object so that GTM does not need to preserve{' '} - data-* attributes on the injected script element. You can - also pass api, storage, and other options via{' '} - pulseConfig. + That's it. Pulse auto-detects the domain from the page, so no extra + configuration is needed.

- Alternative: inline data attributes (may not work in all GTM setups) + Advanced: override domain or configure options - {``} +

+ If your site is registered under a different domain than the page + hostname, or you need custom options (API endpoint, storage mode, etc.), + use pulseConfig: +

+ {` +`}