Skip to content

ScriptGoogleAdsensedata-ad-layout="in-feed" is invalid; no data-ad-layout-key support #873

Description

@tiagomatosweb

🐛 The bug

ScriptGoogleAdsense types and documents data-ad-layout="in-feed", but AdSense throws:

TagError: adsbygoogle.push() error: Invalid data-ad-layout value: in-feed

Google in-feed units do not use data-ad-layout. The snippet AdSense generates is:

<insclass="adsbygoogle"
style="display:block"
data-ad-format="fluid"
data-ad-layout-key="-6t+ed+2i-1n-4w"
data-ad-client="ca-pub-XXXXXXXXXXXXXXXX"
data-ad-slot="XXXXXXXXXX"></ins>

ScriptGoogleAdsense has no data-ad-layout-key prop. Extra attributes fall through to the wrapper div, not the <ins>, so the layout key cannot be passed through.

Valid data-ad-layout in AdSense is in-article. in-feed in the component prop union looks like a mix-up with data-ad-layout-key.

Minimal reproduction:

<template>
<ScriptGoogleAdsense
data-ad-slot="YOUR_IN_FEED_SLOT"
data-ad-format="fluid"
data-ad-layout="in-feed"
:data-full-width-responsive="false"
/>
</template>

Docs: https://scripts.nuxt.com/scripts/google-adsense#using-the-scriptgoogleadsense-component

🛠️ To reproduce

none

🌈 Expected behavior

Either:

  1. Add a data-ad-layout-key prop and bind it on the <ins>, and remove in-feed from data-ad-layout, or
  2. Document that in-feed units must be a raw <ins>, and that data-ad-layout is only for in-article.

The docs currently list data-ad-layout as in-article, in-feed, fixed: https://scripts.nuxt.com/scripts/google-adsense#using-the-scriptgoogleadsense-component

ℹ️ Additional context

  • @nuxt/scripts1.3.2 (same on current main)
  • Component props today:
dataAdFormat?: 'auto'|'rectangle'|'vertical'|'horizontal'|'fluid'|'autorelaxed'
dataAdLayout?: 'in-article'|'in-feed'|'fixed'

The <ins> only binds:

  • data-ad-client
  • data-ad-slot
  • data-ad-format
  • data-ad-layout
  • data-full-width-responsive

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions