How to Add Google Tag Manager in NextJs 14

  Рет қаралды 19,920

Hamed Bahram

Hamed Bahram

Күн бұрын

Пікірлер: 87
@ttirasx
@ttirasx 10 ай бұрын
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 10 ай бұрын
My pleasure! It's great to hear that.
@dotpxg
@dotpxg 9 ай бұрын
Thanks for sharing. Have you found any solutions for the Content Security Policy error caused by the inline GTM? Please please help.
@hamedbahram
@hamedbahram 9 ай бұрын
Not really! What do you mean by inline GTM?
@dotpxg
@dotpxg 9 ай бұрын
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 9 ай бұрын
@@dotpxg I see 🤔I haven't encountered this before and I'm not sure how to solve this.
@hollycow8171
@hollycow8171 8 ай бұрын
5:58 can we convert that button client component as saperate. also can you show us how to push Data layer method.
@hamedbahram
@hamedbahram 8 ай бұрын
what do you mean by separating the button client component?
@Foused87
@Foused87 10 ай бұрын
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 10 ай бұрын
Have you watched this video? → kzbin.info/www/bejne/mHfVY6dsbaZ0eLM
@Foused87
@Foused87 10 ай бұрын
@@hamedbahram yeah it's reeeealy helpful
@Foused87
@Foused87 10 ай бұрын
@@hamedbahram however there are still some tricky parts when you want to combine it all together
@Foused87
@Foused87 10 ай бұрын
I think you would get a lot of views on the all-in-one tutorial
@arturogonzalez7744
@arturogonzalez7744 9 ай бұрын
Thanks Hamed for your excellent content, it's really helpful
@hamedbahram
@hamedbahram 9 ай бұрын
My pleasure. Glad to hear that!
@mdshafiulislam1813
@mdshafiulislam1813 9 ай бұрын
helpful :). Can you give me any suggestion. when i want to set multiple page track as page it not work properly. Thanks
@hamedbahram
@hamedbahram 9 ай бұрын
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
@alimodz6253
@alimodz6253 10 ай бұрын
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 10 ай бұрын
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.
@kris.pbg.
@kris.pbg. 10 ай бұрын
Hey Hamed, love the content! I'm curious about if this falls into the category of blocked cookies for future Chrome versions?
@hamedbahram
@hamedbahram 10 ай бұрын
Please expand on that... what do you mean by blocked cookies?
@kris.pbg.
@kris.pbg. 10 ай бұрын
"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. 10 ай бұрын
@@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 10 ай бұрын
@@kris.pbg. I see 🤔thanks for sharing this.
@codenameunknown3791
@codenameunknown3791 10 ай бұрын
Excelent content Hamed. Keep it up!
@hamedbahram
@hamedbahram 10 ай бұрын
Appreciated!
@Foused87
@Foused87 10 ай бұрын
Please make a tutorial on how to generate pdfs in next 14 js on server-side. It's really tricky.
@hamedbahram
@hamedbahram 10 ай бұрын
🤔 Interesting. Thanks for the suggestions, I'll work on it.
@marieltorres2873
@marieltorres2873 7 ай бұрын
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 7 ай бұрын
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 7 ай бұрын
@@hamedbahram Thanks for the quick response, Hamed! So, I understand that the marketing team is already handling that part, haha 😅. Thanks!
@hamedbahram
@hamedbahram 7 ай бұрын
@@marieltorres2873 Pleasure, Mariel!
@deceiverrr_
@deceiverrr_ 8 ай бұрын
It tells me Google Tag not found no matter what I do at deployed version as well as local version, ay help?
@hamedbahram
@hamedbahram 8 ай бұрын
I'm not sure why that is.
@alfonsomartinangeles6176
@alfonsomartinangeles6176 6 ай бұрын
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 6 ай бұрын
You have to do that manually by excluding the traffic from your dev domains or local host in your Google analytics.
@sabarish4201
@sabarish4201 6 ай бұрын
i want monitor my pages activated or not in my product for example /product page how many times rendered any suggestions???
@hamedbahram
@hamedbahram 6 ай бұрын
Yes watch this video → kzbin.info/www/bejne/gIG7Z2OnltecoJY
@GracianaBaratti
@GracianaBaratti 10 ай бұрын
Excelente video! Estaba teniendo problemas para configurar google tag manager y con tu tutorial lo logre! muchas gracias
@hamedbahram
@hamedbahram 10 ай бұрын
De nada. Me alegra que haya ayudado!
@uncoolcoder
@uncoolcoder 10 ай бұрын
Hamed.. just want to check, can you read my mind 😀... your video releases match with what I am thinking off . :)
@hamedbahram
@hamedbahram 10 ай бұрын
Haha 😅 I am...
@uncoolcoder
@uncoolcoder 10 ай бұрын
@@hamedbahram Thank you for your contents...
@hamedbahram
@hamedbahram 10 ай бұрын
@@uncoolcoder My pleasure!
@ricardovannoort
@ricardovannoort 8 ай бұрын
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 8 ай бұрын
Good question! I've yet to look into cookie consent implementation using the GTM.
@alishayegh7047
@alishayegh7047 10 ай бұрын
great as always, keep going bro💪💪💪
@hamedbahram
@hamedbahram 10 ай бұрын
Thank you 🙌
@julianmedina9370
@julianmedina9370 10 ай бұрын
should gtmId be defined as an env variable?
@hamedbahram
@hamedbahram 10 ай бұрын
Yes it could.
@douwepausma
@douwepausma 9 ай бұрын
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.
@starlord7526
@starlord7526 10 ай бұрын
please we need a video relating to Supabase, creating multiple tables, establishing relation between them and all
@hamedbahram
@hamedbahram 10 ай бұрын
For sure! I'll have that in mind for future videos.
@jijojosein
@jijojosein 10 ай бұрын
@@hamedbahram yes, this please.
@thedanmwangi
@thedanmwangi 6 ай бұрын
Hello, great video! Does the GoogleTagManager from Next.js work with Tag Containers provisioned server side?
@hamedbahram
@hamedbahram 6 ай бұрын
I don't think so, but its worth trying. Let me know if you found the answer to this.
@en_kratia
@en_kratia 6 ай бұрын
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 6 ай бұрын
My pleasure! haven't had that problem, not sure why that is.
@dreamsachiever212
@dreamsachiever212 10 ай бұрын
always great as usual! thanks
@hamedbahram
@hamedbahram 10 ай бұрын
Thank you! I appreciate that.
@KhalidKhan-wo7xg
@KhalidKhan-wo7xg 10 ай бұрын
Informative video 👍
@hamedbahram
@hamedbahram 10 ай бұрын
Thanks 🙂
@babayaga6172
@babayaga6172 10 ай бұрын
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 10 ай бұрын
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
@ladyeli555
@ladyeli555 5 ай бұрын
This is extremely helpful! Thank you!
@hamedbahram
@hamedbahram 5 ай бұрын
Glad it was helpful!
@geraAlcantara
@geraAlcantara 8 ай бұрын
When will be a video for an cookies consent banner ?
@hamedbahram
@hamedbahram 8 ай бұрын
I came across this tool which you can use for managing user consent → www.cookiebot.com/
@geraAlcantara
@geraAlcantara 8 ай бұрын
​@@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 5 ай бұрын
I am having issues connecting GTM with google analytics :(
@hamedbahram
@hamedbahram 5 ай бұрын
It should be straight forward. What's the problem?
@mohammaddavoodnezhad6238
@mohammaddavoodnezhad6238 Ай бұрын
thanks for sharing!
@hamedbahram
@hamedbahram 19 сағат бұрын
My pleasure!
@roshannayak5982
@roshannayak5982 10 ай бұрын
I am first , Love yr content Sir , also love yr prismic (app router ) video 😎
@hamedbahram
@hamedbahram 10 ай бұрын
Great 👍 I appreciate that.
@Klklpia
@Klklpia 10 ай бұрын
Thanks always!
@hamedbahram
@hamedbahram 10 ай бұрын
My pleasure!
@hulashmahto99
@hulashmahto99 10 ай бұрын
I am finding this tutorial and find this video ❤❤❤
@hamedbahram
@hamedbahram 10 ай бұрын
Hope you like it!
@YongkiAgustin
@YongkiAgustin 6 ай бұрын
thanks, its work
@hamedbahram
@hamedbahram 6 ай бұрын
Welcome 👍
@mehdijafarzade2381
@mehdijafarzade2381 10 ай бұрын
💯💯💯💯
@hamedbahram
@hamedbahram 10 ай бұрын
🫡
@avivshvitzky2459
@avivshvitzky2459 10 ай бұрын
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 10 ай бұрын
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.
On-demand revalidation in NextJs 14
16:57
Hamed Bahram
Рет қаралды 14 М.
Google Analytics Is Dead
10:59
Theo - t3․gg
Рет қаралды 99 М.
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
ССЫЛКА НА ИГРУ В КОММЕНТАХ #shorts
0:36
Паша Осадчий
Рет қаралды 8 МЛН
Google Tag Manager Tutorial for Beginners (2024) with New Google Tag
1:01:26
Analytics Mania - Google Analytics & Tag Manager
Рет қаралды 260 М.
How To Add Page Transitions To NextJS 14 (including Exit Animations)
10:34
How to Add Google Analytics 4 (GA4) in Next.js 14 (GDPR opt-in Cookie Banner)
9:45
Max Rohowsky (Max on Tech)
Рет қаралды 1,9 М.
How to Add Google Adsense in Next.js 14
9:48
WebDevJan
Рет қаралды 10 М.
Button click tracking with Google Tag Manager (2024) || Track clicks with GTM
15:23
Analytics Mania - Google Analytics & Tag Manager
Рет қаралды 9 М.
Dockerize Next.js & Deploy to VPS (EASY!)
19:43
ByteGrad
Рет қаралды 74 М.
Effortless Protected Routes In Next.js Using Middleware
15:20
Code Ryan
Рет қаралды 26 М.
Data Layer in Google Tag Manager || GTM Data Layer Tutorial with examples
22:33
Analytics Mania - Google Analytics & Tag Manager
Рет қаралды 162 М.
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН