Webtiryaki Bulut Themes!

The simplest and fastest way to build great UI for your community.

Google Analytics & Google Adsense in NextJS

  • Thread starter Thread starter Korer
  • Start date Start date
K

Korer

Guest
I want to add Google Analytics and Google Adsense to my website in NextJS. I found this official doc: https://nextjs.org/docs/app/buildin...zing/third-party-libraries#google-tag-manager

According to this, its enough to add:

Code:
 <GoogleTagManager gtmId="GTM-XYZ" />

However, I have problem with understanding how Google adsense works. I know that google adsense require from me to include another script to my head (my account is not approved yet for google ads). The problem is that I want to let user decide whether he accepts analytics and advertisement cookies. I was going to simply remove GoogleTagManager from my head for analytics but what with advertsiement? I.e. I can't remove the Google Ads script because I dont want to remove ads at all so have can I distinguish between "personalized adverts" (user accepted cookies) and "not personalized" adverts? How should I construct my code to handle all cases?
<p>I want to add Google Analytics and Google Adsense to my website in NextJS. I found this official doc: <a href="https://nextjs.org/docs/app/buildin...zing/third-party-libraries#google-tag-manager" rel="nofollow noreferrer">https://nextjs.org/docs/app/buildin...zing/third-party-libraries#google-tag-manager</a></p>
<p>According to this, its enough to add:</p>
<pre><code> <GoogleTagManager gtmId="GTM-XYZ" />
</code></pre>
<p>However, I have problem with understanding how Google adsense works. I know that google adsense require from me to include another <code>script</code> to my <code>head</code> (my account is not approved yet for google ads). The problem is that I want to let user decide whether he accepts <code>analytics</code> and <code>advertisement</code> cookies. I was going to simply remove <code>GoogleTagManager</code> from my head for <code>analytics</code> but what with <code>advertsiement</code>? I.e. I can't remove the Google Ads <code>script</code> because I dont want to remove ads at all so have can I distinguish between "personalized adverts" (user accepted cookies) and "not personalized" adverts? How should I construct my code to handle all cases?</p>
Continue reading...
 
Top