What is a "data-ad-slot" for Google Adsense and why is inline styling required?

5,992

When you create an Adsense ad, you can select it to be either responsive or fixed size.

If it's a fixed size, you'll get the sizing thrown into the ad as part of the styling:

style="display:inline-block;width:728px;height:90x"

However, if you choose a responsive size, it will display something like this:

 style="display:block"
 data-ad-format="auto"
 data-full-width-responsive="true"

If you don't want to use inline styling, you can skip the style tag all together and define it on your css, for example:

<ins class="adsbygoogle myadstyle"

And in your css add something like:

.myadstyle{display:inline-block;width:728px;height:90x}

Regarding your second question, data-ad-slot is the code for the ad unit you've created. If you go to Ads > Ad Units, you'll see all the ads you've created for your account. Each of those has a unique ID which is the value used for that field.

Share:
5,992

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I have this adsense ad code:

    <script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
        style="display:inline-block;width:728px;height:90x"
        data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
        data-ad-slot="6440411535"></ins>
    <script>
    

    source

    What is a data-ad-slot for Google Adsense and why is inline styling required — aren't all ads have a fixed mobile-first styling?

    This question is very much a follow up to this question.

  • JAT86
    JAT86 over 4 years
    Let's say I used the same ad code twice in a single page in order to show two ads, will revenue from the 2nd ad be generated? I had read somewhere in the web that using the same data-ad-slot will not generate any revenue and will only be counted as one.
  • Luis Alberto Barandiaran
    Luis Alberto Barandiaran over 4 years
    @JAT86 You can place the same code multiple times on the page, revenue will generate for each individually, however you won't be able to track which of them generated the revenue. For tracking purposes, you can either create a different ad with a different ad-slot and track it there, or use tracking channels.