mazipan / vue-google-adsense

💰 Vue.js Google Adsense Component with InFeed and InArticle Ads support
https://mazipan.github.io/vue-google-adsense/
MIT License
257 stars 42 forks source link

Problems caused by the official adjustment of adsense #55

Closed 158008001 closed 5 years ago

158008001 commented 5 years ago

Adding a class limit height to an automated ad is no longer valid, and adsense will force an adaptive height. Can I add an attribute to control style? Such as ins-style

mazipan commented 5 years ago

PRs are welcome

vesper8 commented 5 years ago

yes I'm seeing this as well.. trying to get a mobile leaderboard seems to be impossible.. it always displays a medium rectangle instead

this is what I'm using:

      <Adsense
        v-if="ad.valid"
        data-ad-client="ca-pub-xxxxxxxxxxxxxxxxxx"
        data-ad-slot="1234567890"
        ins-class="w320h50"
        data-ad-format="rectangle"
        :data-full-width-responsive="true"
      />
.w320xh50 {
  display:inline-block;
  width:320px !important;
  height:50px !important;
}

You would think this would force a 320x50 banner to show.. but because of (recent?) changes to how Adsense generates the ad, it ends up looking like this:

<ins data-ad-client="ca-pub-xxxxxxxxxxxxxxxxxxx" data-ad-slot="1234567890" data-ad-test="" data-ad-format="horizontal" data-full-width-responsive="true" class="adsbygoogle w320xh50" style="display: block; margin-left: -24px; width: 360px; z-index: 30; height: auto !important;" data-adsbygoogle-status="done">...</ins>

And so the height: auto !important; takes precedence over the height:50px !important; inside my class

This slot isn't even a responsive banner by the way, it's a fixed size 320x50 but it seems that what you set on Adsense's side is completely ignored... the code that Adsense generates does include a style directive.. which your plugin does not currently allow us to set

<!-- leaderboard-mobile -->
<ins class="adsbygoogle"
     style="display:inline-block;width:320px;height:50px"
     data-ad-client="ca-pub-xxxxxxxxxxxxxxxxxxx"
     data-ad-slot="1234567890"></ins>
<script>

So I think that is the problem and the way to fix it is to add a ins-style attribute to mimic how Adsense generates the code

vesper8 commented 5 years ago

@mazipan added PR https://github.com/mazipan/vue-google-adsense/pull/57, followed you and starred your project : )

please merge if all looks good.. thank you!

vesper8 commented 5 years ago

and publish new release : )

mazipan commented 5 years ago

Will releasing new version on 21 Oct 2019, I am on holiday.

mazipan commented 5 years ago

@all-contributors please add @vesper8 for code

allcontributors[bot] commented 5 years ago

@mazipan

I've put up a pull request to add @vesper8! :tada:

mazipan commented 5 years ago

Released on 1.8.0