Skip to content

Conversation

@harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Sep 18, 2025

πŸ”— Linked issue

#482

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

There are instances where we need to override the script src because we'll be loading the script from a different domain. We can do this easily enough using scriptInput: { src: '..' } but we lose the resolved query params when we do this.

This fix preserves query params in input src overrides and the registry src, merging them into one.

<script setup lang="ts">
const { proxy } = useScriptGoogleTagManager({
  id: 'GTM-XXXXXX',
  scriptInput: {
    src: 'https://your-domain.com/gtm.js?foo=bar', // foo query is merged with id=GTM-XXXXXX
  }
})
// src: https://your-domain.com/gtm.js?id=GTM-XXXXXX&foo=bar
</script>

harlan-zw and others added 2 commits September 18, 2025 09:24
Add source option to GoogleTagManagerOptions schema to allow custom GTM script URLs for server-side implementations.

- Add source parameter to GoogleTagManagerOptions
- Update script URL construction to use custom source
- Add documentation and examples for server-side GTM setup

Resolves #482

πŸ€– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
scripts-docs Ready Ready Preview Comment Sep 22, 2025 7:16am
scripts-playground Ready Ready Preview Comment Sep 22, 2025 7:16am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/scripts/@nuxt/scripts@500

commit: a04df6a

@harlan-zw harlan-zw changed the title feat(gtm): add source option fix: merge query parms when overriding scriptInput.src Sep 22, 2025
@harlan-zw harlan-zw marked this pull request as ready for review September 22, 2025 07:12
@harlan-zw harlan-zw merged commit abe57c4 into main Sep 22, 2025
8 of 9 checks passed
@harlan-zw harlan-zw deleted the issue-482-gtm-source-option branch September 22, 2025 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants