Nuxt.js google AdSense return error supported one tag

Viewed 2495

I added config Google Adsense to my nuxt.config.js file:

head: {
    ...
    script: [
        {
            src: 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js',
            'data-ad-client': process.env.VUE_APP_GA_AD || '',
            async: true,
        },
    ],
},

I have an error:

adsbygoogle.push() error: Only one AdSense head tag supported per page. The second tag is ignored.

and warning:

AdSense head tag doesn't support data-n-head attribute.

In the source of the page, I can see the code added to the head tag:

<head>
   ...
   <script data-n-head="ssr" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" data-ad-client="ca-pub-MY_NUMBER" async>
   ...
</head>

How I can resolve it ?

2 Answers

Warning is expected as nuxt seem to be adding extra attribute. This warning doesn't break ads. It's intended to help catch issues where developers might mistype adsbygoogle data attributes.

As for Only one AdSense head tag supported per page again, it shouldn't affect ads. The first head tag should run just fine. Though I'm curious why nuxt.js would insert adsbygoogle it twice.

Related