---
title: "Discussion on \"Integrating Google Analytics 4 with Next.js 📈\" | Hashnode"
description: "Discussion on \"Integrating Google Analytics 4 with Next.js 📈\". Today, I decided to add Google Analytics to my portfolio which was built in Next.js\nAt first, I thought that I could achieve this with react-ga, but after trying to add my GA code I realized that it doesn't support Google Analytics 4, only Universal ..."
url: "https://hashnode.com/posts/integrating-google-analytics-4-with-nextjs/603f72cefb37920a1fc64da7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Integrating Google Analytics 4 with Next.js 📈](https://andrei-zgirvaci.hashnode.dev/integrating-google-analytics-4-with-nextjs?utm_source=hashnode&utm_medium=feed)

Today, I decided to add Google Analytics to my portfolio which was built in Next.js At first, I thought that I could achieve this with react-ga, but after trying to add my GA code I realized that it doesn't support Google Analytics 4, only Universal ...

Mar 3, 2021 · 2 min read · andrei-zgirvaci.hashnode.dev  
Updated Apr 1, 2021  
Read the article

-   [#nextjs](https://hashnode.com/tag/nextjs)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#frontend-development](https://hashnode.com/tag/frontend-development)
-   [#google](https://hashnode.com/tag/google)
-   [#analytics](https://hashnode.com/tag/analytics)

## Written by

[Andrei Zgirvaci](https://hashnode.com/@andrei-zgirvaci)

@andrei-zgirvaci · Bali, Indonesia

  
[View profile](https://hashnode.com/@andrei-zgirvaci)

React Native Developer | Mentor

Software Developer with over 7 years of experience building Mobile Apps and Websites. Founder of multiple startups, two of which have been featured in Forbes and one that won the Cellerant Best of Class Technology Award for emerging dental products.

## Responses 2

Markdown supported · ⌘↵ to post

[Matheus Paiva](https://hashnode.com/@matheuspaiva)

[Jun 26, 2021](https://hashnode.com/posts/integrating-google-analytics-4-with-nextjs/603f72cefb37920a1fc64da7/comment/60d721abcb0aa8118c23b495)

Hello, thank you for the guidance!

I don't know a lot about analytics and I am having a hard time trying to identify which ID is the right ID to use with GA4.

My company uses Google Analytics and the ID has this shape: UA-xxxxxxxx-x, but I think this is not the ID I should be using with this estrategy, right?

Is it the google tag manager ID? Or something else? Thank you!

[Andrei Zgirvaci](https://hashnode.com/@andrei-zgirvaci)

[Jun 28, 2021](https://hashnode.com/posts/integrating-google-analytics-4-with-nextjs/603f72cefb37920a1fc64da7/comment/60d721abcb0aa8118c23b495#reply-60d95c3b68364a2e7b2cd78d)

Thanks!

It looks like you are using [Universal Analytics](https://support.google.com/analytics/answer/2790010). In that case, I suggest you use [react-ga](https://github.com/react-ga/react-ga) library to manage your Google Analytics.

Hope this helps :)

[Matheus Paiva](https://hashnode.com/@matheuspaiva)

[Jun 28, 2021](https://hashnode.com/posts/integrating-google-analytics-4-with-nextjs/603f72cefb37920a1fc64da7/comment/60d721abcb0aa8118c23b495#reply-60d95f5d703d372ea06c712d)

[Andrei Zgirvaci](https://hashnode.com/@andrei-zgirvaci) yep! I ended up just doing that and it worked very well. Thank you!

[Tomer Almog](https://hashnode.com/@develop4life)

[May 25, 2021](https://hashnode.com/posts/integrating-google-analytics-4-with-nextjs/603f72cefb37920a1fc64da7/comment/60ac8e5761f5f47b572b7137)

Thank you for this. One thing - the custom events are not showing up on GA. This seems like the old event signature.

[Andrei Zgirvaci](https://hashnode.com/@andrei-zgirvaci)

[May 25, 2021](https://hashnode.com/posts/integrating-google-analytics-4-with-nextjs/603f72cefb37920a1fc64da7/comment/60ac8e5761f5f47b572b7137#reply-60ac9663f06aaf7b7c3e0867)

Hmm, was a while since I have used Google Analytics. Not sure what's going on.

Maybe checking the repo issues will help...
