Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuxt generate #16

Closed
kruny1001 opened this issue Feb 25, 2018 · 15 comments
Closed

nuxt generate #16

kruny1001 opened this issue Feb 25, 2018 · 15 comments

Comments

@kruny1001
Copy link

kruny1001 commented Feb 25, 2018

It seems spa version doesn't work.
adsbygoogle.push() error: Only one 'enable_page_level_ads' allowed per page.

This question is available on Nuxt.js community (#c6)
@Coletrane
Copy link

Coletrane commented Mar 27, 2018

can confirm I'm seeing this issue too. The <script> tag for is getting added twice, once in head, once in body.

@Denoder
Copy link

Denoder commented Jan 1, 2019

any solution for this?

@nmbakfm
Copy link

nmbakfm commented May 4, 2019

I got this issue too.

@tehfonsi
Copy link

tehfonsi commented May 29, 2019

I worked around this issue using this:

if (process.browser && (!window.adsbygoogle || !window.adsbygoogle.loaded)) {
      (adsbygoogle = window.adsbygoogle || []).push({
        google_ad_client: "<your-ad-id>",
        enable_page_level_ads: true
      });
    }

Open for ideas if someone has a better solution.

@myfreax
Copy link

myfreax commented Sep 12, 2019

@teranode what is process.browser, It can not run in browser

@Denoder
Copy link

Denoder commented Sep 12, 2019

@huangyanxiong01 I'm assuming you were going to @ the other person, but use process.client instead.

@lluishi93
Copy link

lluishi93 commented Dec 4, 2019

@tehfonsi Where did you place that code? I'm having this issue with Nuxt generate as well

@tiofabby
Copy link

I had same issue, I had to remove @nuxtjs/google-adsense from nuxt-config and load script manually with something like below:

let script = document.createElement('script')
script.setAttribute('data-ad-client', 'ca-pub-XXXXXXXXXX')
script.setAttribute('src', 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js')
document.head.appendChild(script )

@bengineer19
Copy link

This seems to be a pretty important issue as this module is essentially unusable in its current state.

Upgrading Nuxt to > 2.10 fixed the bug when running in dev mode and SSR mode (ie it works fine for npm run dev and npm run build && npm run start).
image

However the issue still remains when using nuxt generate. Given that many Nuxt sites are deployed entirely using this mode in production, this issue is fairly major for this module.

I'm happy to assist with a fix if a maintainer can provide some guidance.

@agustinfranc
Copy link

agustinfranc commented Nov 3, 2020

@kruny1001 @bengineer19 @tiofabby hi, i found a solution, no need for this module as we can use the head property. just copy this to nuxt.config.js

https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-head

head: {
    script: [
      {
        "data-ad-client": "ca-pub-xxxxxx",
        src: "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",
      },
    ],
  },

@farnabaz
Copy link
Collaborator

This should fix in the latest beta release. v1.3.0-rc.1
Really appreciate if you can confirm the fix 🙂

@farnabaz
Copy link
Collaborator

Just released v1.3.0.

I close this issue, feel free to reopen it if issue exists in new version

@scajal
Copy link

scajal commented Mar 4, 2021

I'm still facing this issue in v1.3.0.

Copy link
Collaborator

farnabaz commented Mar 5, 2021

Hey @scajal
could you create a simple reproduction project using template.nuxtjs.org?

@SwapnilSoni1999
Copy link

same issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests