3

I have a responsive blog where ads are displayed in the sidebar. On mobile devices however, the sidebar is pushed to the bottom below the posts.

So what I'd like to do is move the ads from the sidebar and insert them into the post itself on mobile devices enter image description here

I do this using javascript:

<div id="main">
    <div id="article">
        <div class="post">
            <p class="intro"></p>
            <p class="text"></p>
        </div>
    </div>
    <div id="sidebar">
        <div class="adbox-1"></div>
    </div>    
</div>

<script>
    jQuery(document).ready(function(){

        // AD REPOSITION
        if ($(window).width() < 769) {
            $('.ad-box1').insertAfter($('.intro'));           
        }
     });
</script>

The ads are always loaded in the sidebar, but if the screen width is below 768px, they will be moved somewhere else.

I wonder if this would violate AdSense terms of service?

  • In my understanding that is not allowed, and this may be what you actually want jsfiddle.net/galeksic/r18v4v8m – galeksic Nov 24 '14 at 22:50
  • Do you have any source on why it wouldn't be allowed? Thanks for the code btw, but I'm afraid I can't use it. I have to move the ad dynamically via javascript, if I use media query + display: none, I'd have to add the ad code manually for every post. – Tony Fire Nov 25 '14 at 15:47
  • That is why I said it is my understanding, because I can't provide source, but (for me) it is obvious: if you would be allowed to move parsed AdSense advertisement, what could stop you to reuse it once again, or few, or several times, maybe even on another pages? That parsed ad have many parameters attached, like timestamp, coordinates on the page, etc. so I believe moving would make it invalid. Btw. I don't see any reason why would you "need to add code manually for every post" if you use media queries, and if you do need, then there might be something wrong with your site design / concept. – galeksic Nov 26 '14 at 12:02
4

I think @media-queries are simpler.

You load the two ad units and under 768px you hide one and show the other. This is valid.

The solution you are using is good but as you insert the new ad unit under 768, you also need to remove the other.

This guide from Google explains what you can't do:

  1. Hiding ad units at anytime (e.g., display:none), unless you're implementing a responsive ad unit.
  2. Implementing AdSense ad code in a way that covers content
  3. Using any means to force the display of more than three AdSense ad units on a page
  4. Manipulating the ad targeting using hidden keywords, IFRAMEs, or any other method
  5. Distributing ads in emails or software
  6. Floating ads or units that slide to attract unwarranted attention

Media queries are possible.

Anyway both of the approaches seems valid by Adsense.

  • The only way for me to load an ad inside the posts is to edit all my post 1 by 1 and mnually add an ad code for each one. If both approaches are valid, moving the ad dynamically would be easier. – Tony Fire Nov 25 '14 at 15:49
  • I supposed you were using a CMS, if so you don't need to edit the posts 1 by 1. – nunorbatista Nov 25 '14 at 16:51
  • I'm using Tumblr which limits my ability to manipulate posts as I don't have access to server-side script. That's why I have to move it dynamically through javascript. I'm still uncertain about this method as @galeksic thinks it does violate Google's TOS. – Tony Fire Nov 26 '14 at 14:47
  • a) not being able to edit posts one by one is not a valid reason b) even the officially approved AdSense code (with media queries) won't move already rendered (existing) advertisement from sidebar into the post: it will request another ad from the post, for the post. That is completely different and for me it is obvious that .insertAfter() is not an option. c) If you want, we can continue on productforums.google.com/d/msg/adsense/v6LkFTCLBZM/3M1QAb15B7MJ and if you get the official answer, I think it would be nice if you could update your question here with that answer. – galeksic Nov 27 '14 at 10:01
  • For what I read, it is a valid approach because we're not changing the original code of the ad and we're not floating or sliding the ads to attract attention. The fact is that, if the user is accessing from a device with under 768px, nothing will be moved but directly loaded with the appropriate requests from the ad. The only way the ad will move is if you load on a desktop and resize the screen, otherwise the request will be original, and even in this situation seems valid. – nunorbatista Nov 27 '14 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.