Title: Ad issue, on mobile
Last modified: April 28, 2021

---

# Ad issue, on mobile

 *  Resolved [arafail](https://wordpress.org/support/users/arafail/)
 * (@arafail)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/)
 * Hello!
    I recently noticed an issue with the mobile ads. The issue was not present
   a couple of months ago and it is really baffling. Here goes:
 * 1: Go to this url, on mobile (chrome dev tools is fine) – [https://www.digitalcitizen.ro/activeaza-nu-urmari-dnt-chrome-firefox-edge-opera-internet-explorer/](https://www.digitalcitizen.ro/activeaza-nu-urmari-dnt-chrome-firefox-edge-opera-internet-explorer/)
   
   2: if you scroll you will see several ad blocks, marked by “Advertisement” and
   a light grey frame – [https://www.screencast.com/t/rpVKg3VR7p](https://www.screencast.com/t/rpVKg3VR7p)
   As you can see in the screen capture, the ad block has the following properties:**
   style=”width: 375px; height: 300px; margin-left: -28px;” width: 100vw height:
   320 3: If you check the source of the page (Ctrl+U) you will see that that code
   is different: <amp-ad class=”digcit-ad i-amphtml-layout-fixed i-amphtml-layout-
   size-defined” type=”adsense” layout=”fixed” width=”300″ height=”250″ data-ad-
   slot=”9803205423″ data-ad-client=”ca-pub-6863936848900665″ id=”i-amp-12″ style
   =”width:300px;height:250px;” i-amphtml-layout=”fixed”></amp-ad>
 * Do you have any ideas as to why this happens? Difference in the code seems to
   come from the AMP plugin.
    Thanks!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fad-issue-on-mobile%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14374036)
 * Thanks for reaching out and providing a thorough description of what you’re encountering.
   From inspecting your ads I see various incrementing `data-amp-slot-index` and`
   id` attributes within each ad container. I suspect this may be the ad network
   you’re using or the type of ads. While the dimensions may differ on the ads I
   don’t suspect this is as a result of the AMP plugin.
 * How are you implementing ads on your site, via a plugin or generating ad code
   from AdSense?
 *  Thread Starter [arafail](https://wordpress.org/support/users/arafail/)
 * (@arafail)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14374351)
 * Thanks for the reply!
 * All our ads are hardcoded. You can a sample code below.
    They are responsive 
   ads, with rules for various resolution.
 *     ```
       <div class="block--ad ad-1">
       <amp-ad class="digcit-ad" media="(min-width: 1744px)" type="adsense" layout="fixed" width="970" height="90"  data-ad-slot="5728213132" data-ad-client="ca-pub-6863936848900665"></amp-ad>
   
       <amp-ad class="digcit-ad" media="(min-width: 1168px) and (max-width: 1743px)" type="adsense" layout="fixed" width="728" height="90"  data-ad-slot="5728213132" data-ad-client="ca-pub-6863936848900665"></amp-ad>
   
       <amp-ad class="digcit-ad" media="(min-width: 992px) and (max-width: 1167px)" type="adsense" layout="fixed" width="580" height="400"  data-ad-slot="5728213132" data-ad-client="ca-pub-6863936848900665"></amp-ad>
   
       <amp-ad class="digcit-ad" media="(max-width: 991.98px)" type="adsense" layout="fixed" width="300" height="250"  data-ad-slot="5728213132" data-ad-client="ca-pub-6863936848900665"></amp-ad>
       	</div>
       ```
   
 *  [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14375083)
 * Thanks for providing an update. So you have 4 ads defined within each ad block
   looking at the sample provided? I don’t see any issue from my side when checking
   your ads, with the different ad variations appearing fine based on the screen
   size.
 * I do see that ads sometimes extend beyond the container div (block–ad) on mobile,
   but I don’t see any issues when it comes to the ads being served or [the dimensions](https://recordit.co/yiICXKFTp2).
   If you want to provide more insights into this I’d be happy to see if there is
   something we can assist with.
 *  Thread Starter [arafail](https://wordpress.org/support/users/arafail/)
 * (@arafail)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14375807)
 * The issue I am struggling with is CLS (Cumulative Layout Shift).
    More to the
   point, regarding this ad blocks, the problems seems to be that they are served
   with a different size than they should. The hardcoded size is 300×250 and as 
   you can see (it is also visible in your video), that size gets changed. I have
   narrowed it down to the AMP plugin as I have disabled it on a test environment
   and the code did not change anymore. [⌊2021-04-28_18-27-41⌉](https://www.screencast.com/t/Vsix3evnleSK)
   Thanks!
 *  Thread Starter [arafail](https://wordpress.org/support/users/arafail/)
 * (@arafail)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14376009)
 * Here’s another screenshot were I have highlighted the same code block, on 2 different
   instances: the left one is with the amp plugin inactive, the right one is the
   live website.
 * As you can see on the right, the ad block has been changed to have **width=”100vw”**
   and **height=”320″**. There is also some inline css: style=”width: 375px; height:
   300px; margin-left: -14px;”.
 * [⌊2021-04-28_19-07-46⌉⌊2021-04-28_19-07-46⌉[
 * Thanks!
 *  Thread Starter [arafail](https://wordpress.org/support/users/arafail/)
 * (@arafail)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14380124)
 * Hello!
    Did you get a chance to look at this further?
 *  [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14380167)
 * Hi [@arafail](https://wordpress.org/support/users/arafail/),
 * Apologies, I didn’t get around to this yet but I will put some time aside to 
   recreate a similar ad unit with various media rules. This may be tomorrow before
   I get a change to investigate further.
 * In the meantime as you’re using various ads dependent on the screen size can 
   you share whether you’ve attempting using one of the AMP compatible ads plugins
   to perform the same action, with [Advanced Ads](https://wordpress.org/plugins/advanced-ads/)
   and [AdInserter](https://wordpress.org/plugins/ad-inserter/) allowing for different
   as per screensize.
 *  [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14385191)
 * Thanks for your patience on this. I’ve tested a similar setup to your own and
   I don’t encounter any issues. What seems to be occurring if you have a particular
   ad unit created on the AdSense side with fixed dimensions. It looks like you’re
   then changing the dimensions of the ad unit within your ad variation code. When
   doing so as you’ll see in [this video I created](https://recordit.co/PKYQDb41SX)
   the ad unit dimensions as defined at AdSense level will be used.
 * Have you tried using an ad unit but using the response type? When adding a responsive
   ad type (evident from a `data-auto-format="rspv"` tag) the ad units dimensions
   should better suit your ad variations, without having to manually define the 
   same ad unit using differing dimensions. This may be a suitable alternative than
   your current setup.
 * While I’m not an expert on amp-ads I don’t think the issue itself is specific
   to the AMP plugin, so if the above doesn’t suit you may fine better support by
   opening an ads rendering based issue using the [amphtml github](https://github.com/ampproject/amphtml).
 *  Thread Starter [arafail](https://wordpress.org/support/users/arafail/)
 * (@arafail)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14393825)
 * Thank you for your reply and sorry for the delay.
    There was a holiday here. 
   I will look into it and get back to you.
 *  Thread Starter [arafail](https://wordpress.org/support/users/arafail/)
 * (@arafail)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14403970)
 * Hello!
    Apologies for the late response. We have managed to track down the culprit
   and fix the CLS issue, and I am happy to report it had nothing to do with the
   AMP plugin. There was an issue with the site header, which loaded 0.3s later 
   than the body and had no fixed height. The entire issue lasted so little that
   the human eye did not see it, however, google did. Thank you very much for your
   support!
 *  Thread Starter [arafail](https://wordpress.org/support/users/arafail/)
 * (@arafail)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14403972)
 * We can close this, Thanks!
 *  [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14404204)
 * Great to hear that you found the cause! Many thanks for sharing the additional
   insights.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Ad issue, on mobile’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/ad-issue-on-mobile/#post-14404204)
 * Status: resolved