How to Add Google Adsense in Next.js 14

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025

Комментарии • 43

  • @vigneshbaskaran631
    @vigneshbaskaran631 Месяц назад +2

    My product doesn’t have any payment.. I want to design in such a way that user should see one minute ad for one credit. It is a blogging platform and I don’t want to keep banner ads all over the place to maintain the clean design

  • @focusme-tv3650
    @focusme-tv3650 3 месяца назад +1

    Very much appreciated. Thanks for the video. 👍

  • @ichoupettev4661
    @ichoupettev4661 Месяц назад +2

    that video was great !

  • @codewithshriekdj
    @codewithshriekdj 6 месяцев назад +2

    I Also Created Same Video But i had the other issue of it have one flaw of the ad loading only if the page is visited first time but if i try to navigate it does load (you have to refresh page for it) so i added dependency of usepathname value and useSearchParams of 'next/navigation' of app router which solves this issue.

  • @mpglearncode
    @mpglearncode 6 месяцев назад +7

    I become This error Message
    AdSense Head Tag doesn’t support data-nscript attribute

  • @prasadbeligala
    @prasadbeligala 8 месяцев назад +3

    Very useful video. Thank you.

  • @indiai078
    @indiai078 10 месяцев назад

    Hey I am facing the issue in my console

  • @preciousegwuenu2938
    @preciousegwuenu2938 9 месяцев назад +1

    Hello, do I need to create different display ads in google ads dashboard to have different id to put in different ad section in my website or I just have to create one and google will show different types of ads on each section? also thanks for this video

    • @webdevjan
      @webdevjan  9 месяцев назад +2

      Hey, in the ads section of adsense, you'll find both manual and auto ads.
      With auto ads, you can enable various types of ads like vignette ads and anchor ads. Auto ads are already enabled and loaded into your website by just injecting the adsense script as shown in the video.
      If you want to include custom ads, simply create responsive custom ads for each section of your page. Each of them will give you a unique id.
      For example, if you have a header, create a specific ad for that section. Similarly, if you want floating side panels that are positioned absolutely, create separate ads for them too.
      This will make it much easier to seperate and identify strong ads in analytics.

    • @preciousegwuenu2938
      @preciousegwuenu2938 9 месяцев назад +1

      @@webdevjan Thank you so much

  • @MdSheikhBorhanUddin
    @MdSheikhBorhanUddin 9 месяцев назад +1

    Showing the same error. I can see these boxes on development and production also. I can not see any ads.

    • @andys_industries
      @andys_industries 7 месяцев назад +1

      did you finally see it, mine is the same

  • @gjohnsx
    @gjohnsx 9 месяцев назад +2

    great video thank you

  • @Psyduck0007
    @Psyduck0007 7 месяцев назад

    Hey, can you tell me how to add adsense ads in astro js site?

  • @soumyadipghosh6563
    @soumyadipghosh6563 6 месяцев назад

    Thank you so much bro

  • @GabrielLogan17
    @GabrielLogan17 8 месяцев назад +1

    Why you hide the ID numbers if this is visible on the public website ?

    • @webdevjan
      @webdevjan  8 месяцев назад +1

      Didn't necessarily wanted people to know what my websites are

    • @GabrielLogan17
      @GabrielLogan17 8 месяцев назад

      @webdevjan ah ok, I see, so there's no problem to me exposed that, right ? Any security problems ?

    • @webdevjan
      @webdevjan  8 месяцев назад +2

      @@GabrielLogan17 No, absolutely not. The publisher id will always be exposed to the client, so no worries :)

    • @GabrielLogan17
      @GabrielLogan17 8 месяцев назад +2

      @@webdevjan By the way, thanks.

  • @vitorsousa6126
    @vitorsousa6126 9 месяцев назад

    Doesnt work for me. I follow these steps, but in production I have that issue "DO NOT SUBMIT disabled?" and google API returns 400 error code

    • @thomasmoser4871
      @thomasmoser4871 9 месяцев назад +1

      Hi! Did you make sure your ID has only the number after, without 'ca-pub-'? because I think he made a mistake in the video, using 'ca-pub-{id}' when integrating AdSense, only the Id is needed

    • @vitorsousa6126
      @vitorsousa6126 9 месяцев назад

      @@thomasmoser4871 I use “ca-pub-id”. Because on google docs this is the right way. But I will try with only id

  • @thuanvan9686
    @thuanvan9686 8 месяцев назад

    Thank you very much

  • @shubhpatel_18
    @shubhpatel_18 7 месяцев назад

    do we need cookie banner for Adsense? what if user denies to have cookie, will Adsense revenue drop?

    • @webdevjan
      @webdevjan  7 месяцев назад

      AdSense has an inbuilt cookie consent screen that you need to enable in their dashboard. Once done, as soon as you load the adsense script as shown in the video, the cookie consent screen should automatically show.

    • @webdevjan
      @webdevjan  7 месяцев назад

      And yeah if they don't consent, they won't see ads. I have a 97% consent rate on all my pages together. People are used to hitting "Consent" so don't worry too much about it

    • @shubhpatel_18
      @shubhpatel_18 7 месяцев назад

      @@webdevjan thanks for letting me know this things. Also, i use google analytics for which i have been using banner, so after adsense, do i have to show 2 banner? One for adsense (turned on from dashboard) and another for google analytics?

  • @cameronyking
    @cameronyking 9 месяцев назад

    How to do video ads?

  • @thomasmoser4871
    @thomasmoser4871 9 месяцев назад +1

    For your error, I'd say, set reactStrictMode: false in your next.config.js file

    • @GabrielLogan17
      @GabrielLogan17 8 месяцев назад +4

      This is a st u p i d recommendation.... It's like type everything any and it should work..

  • @bfzli
    @bfzli 8 месяцев назад

    This video lacks, it doesn't show the ads running locally, which by default they don't run.

    • @webdevjan
      @webdevjan  8 месяцев назад +1

      You can't "run" ads locally...
      Google adsense doesn't provide you with an option to whitelist stuff like localhost.
      Add proper placeholders to avoid layout shifts and verify that the ads are loaded just as demonstrated in the video.
      Once you deploy to production and adsense accepted your domain you will see the ads.
      How do I know? I have 3 websites that are using the same code and are all using adsense without any issues.

    • @bfzli
      @bfzli 8 месяцев назад

      @@webdevjan i saw some options for Adsense on local, trying to test that!

  • @degitgitagitya9473
    @degitgitagitya9473 8 месяцев назад

    a

  • @boonfeiybf17
    @boonfeiybf17 6 месяцев назад +2

    I think the minor annoying error is because might get push() a few times so I change the code slightly, and the error goes away.
    useEffect(() => {
    const initializeAds = () => {
    if (typeof window !== "undefined" && (window as any).adsbygoogle) {
    try {
    ((window as any).adsbygoogle = (window as any).adsbygoogle || []).push({});
    } catch (error: any) {
    console.log(error.message);
    }
    }
    };
    initializeAds();
    }, []);

    • @marco.braghim
      @marco.braghim 4 месяца назад

      The error is gone, but the ads never shows...

    • @ichoupettev4661
      @ichoupettev4661 Месяц назад

      Thanks for your help, I'm going to try and see if the ads are shown