No video

How to Add Google Tag Manager in NextJs 14

  Рет қаралды 14,266

Hamed Bahram

Hamed Bahram

Күн бұрын

In this video, we'll use the new `@next/third-parties` package to add Google Tag manager, Google Analytics, and embed KZbin video in our NextJs 14 app.
👉🏼 The Ultimate NextJs 14 Course
→ www.hamedbahra...
👉🏼 Project source code
→ github.com/Ham...
👉🏼 Work with me
→ www.hamedbahra...

Пікірлер: 85
@trusht
@trusht 6 ай бұрын
I'm learning about the latest Next.js features firsthand through your videos, which has been immensely helpful. Your dedication to sharing this knowledge is greatly appreciated.
@hamedbahram
@hamedbahram 6 ай бұрын
My pleasure! It's great to hear that.
@uncoolcoder
@uncoolcoder 6 ай бұрын
Hamed.. just want to check, can you read my mind 😀... your video releases match with what I am thinking off . :)
@hamedbahram
@hamedbahram 6 ай бұрын
Haha 😅 I am...
@uncoolcoder
@uncoolcoder 6 ай бұрын
@@hamedbahram Thank you for your contents...
@hamedbahram
@hamedbahram 6 ай бұрын
@@uncoolcoder My pleasure!
@Foused87
@Foused87 6 ай бұрын
Please make a tutorial on how to set up a project with i18n + next-auth (jwt) and SEO (for example opengraph). Recently I did this kind of project for my client based on your tutorials and it was tricky to combine all these things together.
@hamedbahram
@hamedbahram 6 ай бұрын
Have you watched this video? → kzbin.info/www/bejne/mHfVY6dsbaZ0eLM
@Foused87
@Foused87 6 ай бұрын
@@hamedbahram yeah it's reeeealy helpful
@Foused87
@Foused87 6 ай бұрын
@@hamedbahram however there are still some tricky parts when you want to combine it all together
@Foused87
@Foused87 6 ай бұрын
I think you would get a lot of views on the all-in-one tutorial
@Foused87
@Foused87 6 ай бұрын
Please make a tutorial on how to generate pdfs in next 14 js on server-side. It's really tricky.
@hamedbahram
@hamedbahram 6 ай бұрын
🤔 Interesting. Thanks for the suggestions, I'll work on it.
@ricardovannoort
@ricardovannoort 4 ай бұрын
Nice new feature in NextJS. Did you experiment with the data layer in order to deny storage and grant it when cookies are accepted? NextJS refers to Google for this and Google has documented it poorly.
@hamedbahram
@hamedbahram 4 ай бұрын
Good question! I've yet to look into cookie consent implementation using the GTM.
@avivshvitzky2459
@avivshvitzky2459 5 ай бұрын
This video is kinda misleading. You didn't show how to actually add GA14, you just showed a custom event you made for a click, and only said in general that you can somehow connect your tag manager to GA14, but didnt show how to do it
@hamedbahram
@hamedbahram 5 ай бұрын
Sorry you think that way! However, connecting GA4 to Google tag manager is not a NextJs specific implementation, and I'm sure there are a ton of videos out there that'll show you how to do that better than I would. The point of this video is to learn about the `@next/third-parties` package that makes it easy to install GTM or GA4 in NextJs.
@arturogonzalez7744
@arturogonzalez7744 4 ай бұрын
Thanks Hamed for your excellent content, it's really helpful
@hamedbahram
@hamedbahram 4 ай бұрын
My pleasure. Glad to hear that!
@codenameunknown3791
@codenameunknown3791 6 ай бұрын
Excelent content Hamed. Keep it up!
@hamedbahram
@hamedbahram 6 ай бұрын
Appreciated!
@en_kratia
@en_kratia 2 ай бұрын
Very useful video, thank you. For some reason GoogleTagManager placed in Layout is breaking HMR for some (random?) pages/components. I spend several hours to find out this. When it placed in Page - no problem. Thank you one more time, Excellent video.
@hamedbahram
@hamedbahram 2 ай бұрын
My pleasure! haven't had that problem, not sure why that is.
@starlord7526
@starlord7526 6 ай бұрын
please we need a video relating to Supabase, creating multiple tables, establishing relation between them and all
@hamedbahram
@hamedbahram 6 ай бұрын
For sure! I'll have that in mind for future videos.
@jijojosein
@jijojosein 6 ай бұрын
@@hamedbahram yes, this please.
@kris.pbg.
@kris.pbg. 6 ай бұрын
Hey Hamed, love the content! I'm curious about if this falls into the category of blocked cookies for future Chrome versions?
@hamedbahram
@hamedbahram 6 ай бұрын
Please expand on that... what do you mean by blocked cookies?
@kris.pbg.
@kris.pbg. 6 ай бұрын
"If your site uses third-party cookies, it's time to take action. To facilitate testing, Chrome has restricted third-party cookies by default for 1% of users. Subject to addressing any remaining competition concerns of the UK's Competition and Markets Authority, Chrome will ramp up third-party cookie restrictions to 100% of users from Q3 2024." That's from developers.google@@hamedbahram
@kris.pbg.
@kris.pbg. 6 ай бұрын
@@hamedbahram "If your site uses third-party cookies, it's time to take action. To facilitate testing, Chrome has restricted third-party cookies by default for 1% of users. Subject to addressing any remaining competition concerns of the UK's Competition and Markets Authority, Chrome will ramp up third-party cookie restrictions to 100% of users from Q3 2024." That's an extract from Google's developers page in the cookie countdown section.
@hamedbahram
@hamedbahram 6 ай бұрын
@@kris.pbg. I see 🤔thanks for sharing this.
@ladyeli555
@ladyeli555 Ай бұрын
This is extremely helpful! Thank you!
@hamedbahram
@hamedbahram Ай бұрын
Glad it was helpful!
@babayaga6172
@babayaga6172 6 ай бұрын
Great Work ❤ Can U please make a video how to secure apis in nextjs like prevent from scrapping And also what about to handle light and dark mode without flicker
@hamedbahram
@hamedbahram 6 ай бұрын
Thanks! You can protect your APIs with authentication → look at my auth videos I've covered light/dark theme in previous videos here → kzbin.info/www/bejne/iIWke2Cbo8uoo9U
@user-lt6ej6tq6v
@user-lt6ej6tq6v 5 ай бұрын
Excelente video! Estaba teniendo problemas para configurar google tag manager y con tu tutorial lo logre! muchas gracias
@hamedbahram
@hamedbahram 5 ай бұрын
De nada. Me alegra que haya ayudado!
@deceiverrr_
@deceiverrr_ 4 ай бұрын
It tells me Google Tag not found no matter what I do at deployed version as well as local version, ay help?
@hamedbahram
@hamedbahram 4 ай бұрын
I'm not sure why that is.
@alishayegh7047
@alishayegh7047 6 ай бұрын
great as always, keep going bro💪💪💪
@hamedbahram
@hamedbahram 6 ай бұрын
Thank you 🙌
@dreamsachiever212
@dreamsachiever212 6 ай бұрын
always great as usual! thanks
@hamedbahram
@hamedbahram 6 ай бұрын
Thank you! I appreciate that.
@KhalidKhan-wo7xg
@KhalidKhan-wo7xg 6 ай бұрын
Informative video 👍
@hamedbahram
@hamedbahram 6 ай бұрын
Thanks 🙂
@mdshafiulislam1813
@mdshafiulislam1813 5 ай бұрын
helpful :). Can you give me any suggestion. when i want to set multiple page track as page it not work properly. Thanks
@hamedbahram
@hamedbahram 5 ай бұрын
You have to enable the "Enhanced Measurement" for client-side navigation, read more here → nextjs.org/docs/app/building-your-application/optimizing/third-party-libraries#tracking-pageviews
@dotpxg
@dotpxg 5 ай бұрын
Thanks for sharing. Have you found any solutions for the Content Security Policy error caused by the inline GTM? Please please help.
@hamedbahram
@hamedbahram 5 ай бұрын
Not really! What do you mean by inline GTM?
@dotpxg
@dotpxg 5 ай бұрын
The Content Security Policy (CSP) error occurs due to using inline Google Tag Manager (GTM). I was asking if you could help with any solutions. I have been using middleware for CSP as per next.js14 docs. GTM is being included directly within the body of the HTML, which is causing it to be treated as an inline script and triggering the CSP error. Please help, if you could
@hamedbahram
@hamedbahram 5 ай бұрын
@@dotpxg I see 🤔I haven't encountered this before and I'm not sure how to solve this.
@marieltorres2873
@marieltorres2873 3 ай бұрын
Hi Hamed, thanks for your video, I have a question. Once I add the GTM tag and I also want to add Analytics, do I need to add the other tag below as well, or is GTM enough?
@hamedbahram
@hamedbahram 3 ай бұрын
Once you add the GTM you can add all other tags to your GTM. It works as a container for all your tags like analytics, meta pixel, etc. You have to do it through tagmanager.google.com
@marieltorres2873
@marieltorres2873 3 ай бұрын
@@hamedbahram Thanks for the quick response, Hamed! So, I understand that the marketing team is already handling that part, haha 😅. Thanks!
@hamedbahram
@hamedbahram 3 ай бұрын
@@marieltorres2873 Pleasure, Mariel!
@hulashmahto99
@hulashmahto99 6 ай бұрын
I am finding this tutorial and find this video ❤❤❤
@hamedbahram
@hamedbahram 6 ай бұрын
Hope you like it!
@hollycow8171
@hollycow8171 3 ай бұрын
5:58 can we convert that button client component as saperate. also can you show us how to push Data layer method.
@hamedbahram
@hamedbahram 3 ай бұрын
what do you mean by separating the button client component?
@you3667
@you3667 5 ай бұрын
Thanks always!
@hamedbahram
@hamedbahram 5 ай бұрын
My pleasure!
@sabarish4201
@sabarish4201 2 ай бұрын
i want monitor my pages activated or not in my product for example /product page how many times rendered any suggestions???
@hamedbahram
@hamedbahram 2 ай бұрын
Yes watch this video → kzbin.info/www/bejne/gIG7Z2OnltecoJY
@thedanmwangi
@thedanmwangi 2 ай бұрын
Hello, great video! Does the GoogleTagManager from Next.js work with Tag Containers provisioned server side?
@hamedbahram
@hamedbahram 2 ай бұрын
I don't think so, but its worth trying. Let me know if you found the answer to this.
@alfonsomartinangeles6176
@alfonsomartinangeles6176 Ай бұрын
Does this component handle the condition to run only in production? or should I put a condition manually to run on prod only? Thank you!
@hamedbahram
@hamedbahram Ай бұрын
You have to do that manually by excluding the traffic from your dev domains or local host in your Google analytics.
@alimodz6253
@alimodz6253 5 ай бұрын
Hi thanks for the video, I have a question because I am a bit confused in the next js docs. Is the "sendGTMEvent" method the same as "sendGAEvent"? I was already tracking page views before using the script tags in next js, now I am trying to add GA4 events. So do I use the sendGTMEvent to send GA4 events or do I only import sendGAEvent for that?
@hamedbahram
@hamedbahram 5 ай бұрын
It depends which one you were using before, if you were using GTM before, you can use GTM events, if you were using GA4 before directly, use the GA4 events. Tag manager is just a central container to hold all different sorts of tags, like the GA4, Meta pixel, etc.
@roshannayak5982
@roshannayak5982 6 ай бұрын
I am first , Love yr content Sir , also love yr prismic (app router ) video 😎
@hamedbahram
@hamedbahram 6 ай бұрын
Great 👍 I appreciate that.
@geraAlcantara
@geraAlcantara 4 ай бұрын
When will be a video for an cookies consent banner ?
@hamedbahram
@hamedbahram 4 ай бұрын
I came across this tool which you can use for managing user consent → www.cookiebot.com/
@geraAlcantara
@geraAlcantara 4 ай бұрын
​@@hamedbahram Thank you, I saw that one before, however I think that solution will impact the LCP, I was hoping to see your approach to use a cookies consent banner along with next/third-parties/google and GoogleAnalytics or GoogleTagManager Components, and see how it was set for conditionally use it on the root layout base on the consent
@hebe_lia
@hebe_lia 19 күн бұрын
I am having issues connecting GTM with google analytics :(
@hamedbahram
@hamedbahram 16 күн бұрын
It should be straight forward. What's the problem?
@YongkiAgustin
@YongkiAgustin Ай бұрын
thanks, its work
@hamedbahram
@hamedbahram Ай бұрын
Welcome 👍
@julianmedina9370
@julianmedina9370 5 ай бұрын
should gtmId be defined as an env variable?
@hamedbahram
@hamedbahram 5 ай бұрын
Yes it could.
@douwepausma
@douwepausma 5 ай бұрын
For security reasons it's not necessary as it will be rendered in the DOM anyways. But if you're deploying with something like Vercel I can definitely recommend it, because you can change it easily later on without having to make code changes.
@mehdijafarzade2381
@mehdijafarzade2381 6 ай бұрын
💯💯💯💯
@hamedbahram
@hamedbahram 6 ай бұрын
🫡
10 common mistakes with the Next.js App Router
20:37
Vercel
Рет қаралды 205 М.
Google Tag Manager Tutorial for Beginners (2024) with New Google Tag
1:01:26
Analytics Mania - Google Analytics & Tag Manager
Рет қаралды 201 М.
🩷🩵VS👿
00:38
ISSEI / いっせい
Рет қаралды 24 МЛН
Harley Quinn's revenge plan!!!#Harley Quinn #joker
00:59
Harley Quinn with the Joker
Рет қаралды 27 МЛН
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 37 МЛН
Global State Management in NextJs 14 Using Zustand
51:17
Hamed Bahram
Рет қаралды 26 М.
Google Analytics Is Dead
10:59
Theo - t3․gg
Рет қаралды 94 М.
Next 14 + React Query COMBO with Server Actions and RSC
9:49
developedbyed
Рет қаралды 100 М.
The Greenwich Meridian is in the wrong place
25:07
Stand-up Maths
Рет қаралды 821 М.
The Story of Next.js
12:13
uidotdev
Рет қаралды 566 М.
Future Proof Your Tech Career In the Age of AI
10:21
Travis Media
Рет қаралды 35 М.
Google Tag Manager vs Google Analytics. What’s the difference?
8:25
Analytics Mania - Google Analytics & Tag Manager
Рет қаралды 105 М.
DiagramGPT - Honest Review of Eraser AI
8:22
Sam Meech-Ward
Рет қаралды 126 М.
Next.js 15 Ruins Caching Even More
13:56
Web Dev Simplified
Рет қаралды 44 М.
I tried every website builder. This is the BEST
19:31
Steve Builds Websites
Рет қаралды 75 М.
🩷🩵VS👿
00:38
ISSEI / いっせい
Рет қаралды 24 МЛН