Skip to content
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

App router migration google tag manager script #1117

Open
wants to merge 13 commits into
base: next-js-migration
Choose a base branch
from

Conversation

boodland
Copy link
Contributor

@boodland boodland commented Sep 2, 2024

Children PR for the progressive migration of _app.tsx and _document.tsx within the Root Layout

Issue link / number:

#1083

What changes did you make?

Changed script strategy to afterInteractive as worker doesn't work for app router
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts#offloading-scripts-to-a-web-worker-experimental
https://nextjs.org/docs/pages/api-reference/components/script#afterinteractive
Added google tag manager configuration to root layout
Moved Script from _document to _app as recommended in the pages router documentation
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts#application-scripts
https://nextjs.org/docs/pages/api-reference/components/script#afterinteractive
Added comment about new approach not being used due to how events are pushed to the dataLayer

Why did you make the changes?

In order to be able to have google tag manager within app router

Did you run tests?

Yes

Navigate to http://localhost:3000/ to check that the head gtag and body scripts are added properly
image

Navigate to http://localhost:3000/public-route-test to check that the head gtag and body scripts are added properly

image

Copy link

vercel bot commented Sep 2, 2024

@boodland is attempting to deploy a commit to the Chayn Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Sep 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bloom-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 16, 2024 9:19am

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.

1 participant