phpbb-extensions/ad-management

Unworkable ad code

rxu opened this issue · 11 comments

rxu commented

There's a pair of examples where the code given by Google and Yandex won't be shown. The extension code analyzer reports the code is ok.

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 2017.08.01 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-6052584654693494"
     data-ad-slot="5495024367"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- Yandex.RTB R-A-161344-1 -->
<div id="yandex_rtb_R-A-161344-1"></div>
<script type="text/javascript">
    (function(w, d, n, s, t) {
        w[n] = w[n] || [];
        w[n].push(function() {
            Ya.Context.AdvManager.render({
                blockId: "R-A-161344-1",
                renderTo: "yandex_rtb_R-A-161344-1",
                async: true
            });
        });
        t = d.getElementsByTagName("script")[0];
        s = d.createElement("script");
        s.type = "text/javascript";
        s.src = "//an.yandex.ru/system/context.js";
        s.async = true;
        t.parentNode.insertBefore(s, t);
    })(this, this.document, "yandexContextAsyncCallbacks");
</script>

This is a user problem!

I don't know what Yandex is, but the Google ad code is fine. The problem is the user does not know how the code they're using works!

That is Google's Responsive Ad Code. Their responsive ad code works by auto calculating the height and width of whatever it is contained in, and resizing the ad dynamically to fit that containing element.

Thus, it requires a containing element with sizing.

This extension places ads in a div container, but our div is based on the size of the content and CAN NOT pre-define a height or width because we have know way of knowing what the content will be...in other words our containig div's height is auto and width is 100%.

Since the height is auto, with the responsive Google Ad code, the height is automatically 0, thus you don't see anything.

The person usig that code should either:

  1. Use a standard Google Adsense ad code that is not responsive.
  2. Wrap their responsive Google ad code in a div and set its width to 100% and height to a number that works for whatever the size of the ads they are displaying is.
rxu commented

User who faced the problem says he don't have any "standard" or "responsive" variants from Google, this is the only one given by GoogleAd. So, from his point of view, the extension simply doesn't work.
Well, all I can say him then just "remove this extension and find another one that works" 😃

They are wrong. When you create an ad, you can choose for it to be standard or responsive. The code and and script you get is different dependingon that choice.

https://support.google.com/adsense/answer/3543893?hl=en&ref_topic=1307438

Create an ad unit in the usual way, making sure to select “Responsive” from the Ad size drop-down in the process, and click Save and get code.

Copy and paste the ad code into the HTML source code of your page where you'd like the ad to appear, keeping in mind that it will dynamically inherit the size of the parent container.

Also the key give-away that the user is using Google's responsive is these lines in his code:

style="display:block"
data-ad-format="auto"

The auto especially is what makes it responsive.
Normal ads have specific ad dimensions, like:

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

@VSEphpbb Well, do we state somewhere that this ext is not for responsive ad? I guess not. Then we should notice that somewhere.
The point is that users have no idea about all things you pointed above. They're just pasting the code which don't work as a result.
Sorry for upsetting you with that 😛

Well, it's not our problem if they make an ad choice and don't read the requirements of that ad choice ;)

@rxu I think my ultimate point here is, with this extension, we are quite simply allowing users to insert any HTML they want into locations in the forum. We can't pre-emptively know and account for what that HTML could ever be be, so that this extension would magically insert whatever they give it exactly and perfectly as they wanted it to appear. So it really is up to the user to "tweak" their code as needed, once they see it in the preview or live on the board.

It really isn't any different if they were inserted the code into their web page. They'd still have to tweak it to make it look the way they want.

There are infinite possibilities of what users could paste into the ad code field here.

Whatever happened to the days where people running a web site knew about HTML and CSS? 😉

At any rate I think I have a solution

Nope. No solution. Fix one thing, break another.

senky commented

Okay, based on few feedbacks from the users, we now know that majority of users use this extension to place Google Ads into the board. Thus, I propose we change the container so that it works fine with responsive Google Ads, rewrite banner upload feature to not only add IMG tag, but also centering DIV; and help every user who has centering problems (if there are any).

👍