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.
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
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.
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
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?
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.
"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
@@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.
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?
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
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.
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.
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.
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
Thanks! You can protect your APIs with authentication → look at my auth videos I've covered light/dark theme in previous videos here → th-cam.com/video/RTAJ-enfums/w-d-xo.html
@@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
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
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.
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.
My pleasure! It's great to hear that.
5:58 can we convert that button client component as saperate. also can you show us how to push Data layer method.
what do you mean by separating the button client component?
Thanks for sharing. Have you found any solutions for the Content Security Policy error caused by the inline GTM? Please please help.
Not really! What do you mean by inline GTM?
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
@@dotpxg I see 🤔I haven't encountered this before and I'm not sure how to solve this.
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.
Have you watched this video? → th-cam.com/video/bFr2t68AABQ/w-d-xo.html
@@hamedbahram yeah it's reeeealy helpful
@@hamedbahram however there are still some tricky parts when you want to combine it all together
I think you would get a lot of views on the all-in-one tutorial
helpful :). Can you give me any suggestion. when i want to set multiple page track as page it not work properly. Thanks
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
Thanks Hamed for your excellent content, it's really helpful
My pleasure. Glad to hear that!
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?
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.
Hey Hamed, love the content! I'm curious about if this falls into the category of blocked cookies for future Chrome versions?
Please expand on that... what do you mean by blocked cookies?
"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
@@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.
@@kris.pbg. I see 🤔thanks for sharing this.
Excelent content Hamed. Keep it up!
Appreciated!
Please make a tutorial on how to generate pdfs in next 14 js on server-side. It's really tricky.
🤔 Interesting. Thanks for the suggestions, I'll work on it.
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?
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
@@hamedbahram Thanks for the quick response, Hamed! So, I understand that the marketing team is already handling that part, haha 😅. Thanks!
@@marieltorres2873 Pleasure, Mariel!
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!
You have to do that manually by excluding the traffic from your dev domains or local host in your Google analytics.
It tells me Google Tag not found no matter what I do at deployed version as well as local version, ay help?
I'm not sure why that is.
i want monitor my pages activated or not in my product for example /product page how many times rendered
any suggestions???
Yes watch this video → th-cam.com/video/JPX60qarij4/w-d-xo.html
Excelente video! Estaba teniendo problemas para configurar google tag manager y con tu tutorial lo logre! muchas gracias
De nada. Me alegra que haya ayudado!
Hamed.. just want to check, can you read my mind 😀... your video releases match with what I am thinking off . :)
Haha 😅 I am...
@@hamedbahram Thank you for your contents...
@@uncoolcoder My pleasure!
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.
Good question! I've yet to look into cookie consent implementation using the GTM.
Hello, great video!
Does the GoogleTagManager from Next.js work with Tag Containers provisioned server side?
I don't think so, but its worth trying. Let me know if you found the answer to this.
should gtmId be defined as an env variable?
Yes it could.
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.
please we need a video relating to Supabase, creating multiple tables, establishing relation between them and all
For sure! I'll have that in mind for future videos.
@@hamedbahram yes, this please.
great as always, keep going bro💪💪💪
Thank you 🙌
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.
My pleasure! haven't had that problem, not sure why that is.
always great as usual! thanks
Thank you! I appreciate that.
Informative video 👍
Thanks 🙂
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
Thanks!
You can protect your APIs with authentication → look at my auth videos
I've covered light/dark theme in previous videos here → th-cam.com/video/RTAJ-enfums/w-d-xo.html
This is extremely helpful! Thank you!
Glad it was helpful!
When will be a video for an cookies consent banner ?
I came across this tool which you can use for managing user consent → www.cookiebot.com/
@@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
I am having issues connecting GTM with google analytics :(
It should be straight forward. What's the problem?
I am first , Love yr content Sir , also love yr prismic (app router ) video 😎
Great 👍 I appreciate that.
thanks for sharing!
Thanks always!
My pleasure!
I am finding this tutorial and find this video ❤❤❤
Hope you like it!
thanks, its work
Welcome 👍
💯💯💯💯
🫡
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
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.