FG
💻 Software🌐 Web & Full-StackVercel

Adding GA script tag?

Freshover 9 years ago
Mar 14, 20260 views
Confidence Score76%
76%

Problem

Hi there! I am currently converting my website to a next.js project and can't figure out on how to add the Google Analytics script tag to the page. Any thoughts? Cheers, Robin

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
75% confidence92% success rate10 verificationsLast verified Mar 14, 2026

Solution: Adding GA script tag?

Low Risk

No need for `react-ga`. Use the google tag manager with the `<Head>` component to inject analytics. There are some small changes to the google tag manager code necessary to make it work in nextjs/react: [code block]

75

Trust Score

10 verifications

92% success
  1. 1

    No need for `react-ga`. Use the google tag manager with the `<Head>` component t

    No need for `react-ga`. Use the google tag manager with the `<Head>` component to inject analytics. There are some small changes to the google tag manager code necessary to make it work in nextjs/react:

Validation

Resolved in vercel/next.js GitHub issue #160. Community reactions: 191 upvotes.

Verification Summary

Worked: 10
Partial: 2
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

nextjsreactssr