Skip to content

fix(analytics): replace manual GA4 script with @next/third-parties/google#113

Merged
sktbrd merged 1 commit into
r4topunk:mainfrom
mtlouzada:fix/ga4-third-parties
May 29, 2026
Merged

fix(analytics): replace manual GA4 script with @next/third-parties/google#113
sktbrd merged 1 commit into
r4topunk:mainfrom
mtlouzada:fix/ga4-third-parties

Conversation

@mtlouzada

Copy link
Copy Markdown
Contributor

Summary

  • Substitui a implementação manual de GA4 (dois <Script> tags + inline gtag config) pelo helper oficial GoogleAnalytics de @next/third-parties/google
  • O helper monta o dataLayer, injeta o script do GTM e dispara config/pageviews corretamente
  • Measurement ID continua lendo NEXT_PUBLIC_GA_ID com fallback para "G-S0R9RBJDKL", nenhuma env var precisa mudar

Changes

  • src/components/analytics/GoogleAnalytics.tsx — reescrito para usar @next/third-parties/google
  • package.json / pnpm-lock.yaml — nova dependência @next/third-parties

Como testar no F12

  1. pnpm dev e abra qualquer página
  2. Network → filtre por collect — deve aparecer uma requisição POST para https://www.google-analytics.com/g/collect com status 204
  3. Network → filtre por gtag — deve aparecer a requisição do script gtag/js?id=G-S0R9RBJDKL
  4. Console → rode window.dataLayer — deve retornar um array com os objetos {0: "js", ...} e {0: "config", 1: "G-S0R9RBJDKL", ...}
  5. Navegue entre páginas (ex: /proposals/auctions) e repita o passo 2 — um novo collect deve aparecer a cada troca de rota confirmando os pageviews

Test plan

  • Requisição collect com status 204 aparece no Network ao carregar a página
  • Script gtag/js carregado no Network
  • window.dataLayer populado no console
  • Novo collect disparado a cada navegação entre rotas

Generated with Claude Code

@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

@mtlouzada is attempting to deploy a commit to the r4to's projects Team on Vercel.

A member of the Team first needs to authorize it.

@sktbrd sktbrd merged commit b9d332b into r4topunk:main May 29, 2026
1 of 3 checks passed
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