fix: support GTM and tag managers via window.pulseConfig fallback

Script detection now also searches by src URL and supports a global
config object (window.pulseConfig) for environments where data-*
attributes are not preserved on the injected script element.
This commit is contained in:
Usman Baig
2026-03-19 13:45:21 +01:00
parent bf3097c26e
commit 73fc47e910
2 changed files with 48 additions and 12 deletions

View File

@@ -2298,15 +2298,32 @@ export default defineConfig({
<p>Follow these steps to add Pulse through GTM:</p>
<ol>
<li>Go to <strong>Tags &rarr; New &rarr; Custom HTML</strong></li>
<li>Paste the Pulse script</li>
<li>Paste the snippet below (replace <code>your-site.com</code> with your domain)</li>
<li>Set the trigger to <strong>All Pages</strong></li>
<li>Publish your container</li>
</ol>
<CodeBlock filename="GTM → Custom HTML Tag">{`<script
<CodeBlock filename="GTM → Custom HTML Tag (recommended)">{`<script>
window.pulseConfig = { domain: "your-site.com" };
</script>
<script defer src="https://pulse.ciphera.net/script.js"></script>`}</CodeBlock>
<p>
This uses a global config object so that GTM does not need to preserve{' '}
<code>data-*</code> attributes on the injected script element. You can
also pass <code>api</code>, <code>storage</code>, and other options via{' '}
<code>pulseConfig</code>.
</p>
<details>
<summary className="cursor-pointer text-sm text-neutral-500 dark:text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-300">
Alternative: inline data attributes (may not work in all GTM setups)
</summary>
<CodeBlock filename="GTM → Custom HTML Tag (alternative)">{`<script
defer
data-domain="your-site.com"
src="https://pulse.ciphera.net/script.js"
></script>`}</CodeBlock>
</details>
<p>
For more details, see the{' '}