Skip to content

Refactor GTM implementation to support google tag gateway #81011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

gusfune
Copy link

@gusfune gusfune commented Jun 27, 2025

What?

This PR refactors the Google Tag Manager implementation on @next/third-parties, it rewrites the implementation of the script url, params and types to allow gtmId to be optional when a script URL is provided.

Why?

Google released Google Tag Gateway for Advertisers which allows first-party tracking on GTM. When running GTM using the current implementation, it doesn't work because the ?id= is hardcoded into the implementation as it doesn't consider the possibility of tag gateway or any other setup where the ID is already part of the url.

How?

  • Expanded the types
  • Refactored the initialisation of the script URL
  • Updated documentation relevant to GTM

Closes #81009

@ijjk ijjk added the Documentation Related to Next.js' official documentation. label Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Related to Next.js' official documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants