[OzzModz] Google Adsense tips and visual overview of ad positions

[OzzModz] Google Adsense tips and visual overview of ad positions

Hi, instead of adsense, try entering some plain text and see if it activates.

99 percent of the time it is an adsense detection problem. The guides listed here work on the safe side (except for forums that contain articles)

Thanks. I'm using Google Ad Manager positions for this. Anyway I just put in some text and it did show up correctly. I think it may have to do with GAM not being able to call the same ad multiple times, I may have to just setup 3 positions for this instead of using the combination code.
 
It might also take some time (hours/days) before Google fills all ad (new) spaces.
Even if you use the same code, they will see the different positions and try to find matching ads.
Let us know if setting up 3 separate positions makes a difference.
 
This code for After first post location:
Code:
$post.position % $xf.options.messagesPerPage == 0

Doesn't work on article page/1st page.
But works fine on question forums.

Any replacement for that on XF 2.2?
Ah, I see. If it is an article, the first post/reply is at position 1 instead of 0, but this only counts for the first page.
This makes it more complicated, but try this:

Code:
$post.position % $xf.options.messagesPerPage == 0 OR ($__globals.thread.discussion_type == 'article' AND $post.position == 1)
 
Hello,
I used the code as described and it doesn't look right, see the spaces in between the ads. Any suggestions? And is there a way to make it the full length of the forums?

Screen Shot 2021-01-22 at 6.23.19 PM.webp
 
You can force the ads to be horizontal ads by adding data-ad-format="horizontal". This will render them full width, if available.
Additionally I also added data-full-width-responsive="false" which prevents huge ads on mobile devices.

The spacing can be solved with margins.

Here's an example I used

HTML:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

<div style="margin:3px 0 3px 0;">
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="xxx"
         data-ad-slot="xxx"
         data-ad-format="horizontal"
         data-full-width-responsive="false"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
</div>
 
You can force the ads to be horizontal ads by adding data-ad-format="horizontal". This will render them full width, if available.
Additionally I also added data-full-width-responsive="false" which prevents huge ads on mobile devices.

The spacing can be solved with margins.

Here's an example I used

HTML:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

<div style="margin:3px 0 3px 0;">
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="xxx"
         data-ad-slot="xxx"
         data-ad-format="horizontal"
         data-full-width-responsive="false"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
</div>
Thanks for that, I find it odd I have to use such extreme margins for it to sit right in respect to spacing. Is it my custom style perhaps? I using Safari and viewing it on a Mac. Here is a page on my site, it's the 2 ads I'm working with, "after first post" and "before last post." https://sphynxlair.com/community/threads/cleo-and-joey.49594/

Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==0">
    <div style="margin:-2px 0 28px 0;">
 
Maybe you can try this instead of using the DIV:

Code:
<article class="message message--post">
... adsense code ...
</article>

This way, it will use the same dimensions as a normal post.
 
Ooops! It added double ads after each post after I did the same code on "before last post." Hmmm.
 
I can't think of anything, it should not matter whether you use div or article.
Weird.. there must an error somewhere. Can you share your exact code?
 
I can't think of anything, it should not matter whether you use div or article.
Weird.. there must an error somewhere. Can you share your exact code?
This is the code straight from Adsense, nothing added.

Code:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Before last post -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="xxx"
     data-ad-slot="xxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
 
This was with your code from here originally.

Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==count($__globals.posts) - 2 AND count($__globals.posts)>2">
    <div style="margin: 0px 0 29px 0;">
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Before last post -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="xxx"
     data-ad-slot="xxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
    </div>
</xf:if>
 
So if you want the arctile layout for your add, it should look like this:

Position: Post: Below message container

Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==count($__globals.posts) - 2 AND count($__globals.posts)>2">
    <article class="message message--post">
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Before last post -->
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="xxx"
         data-ad-slot="xxx"
         data-ad-format="horizontal"
         data-full-width-responsive="false"></ins>
    <script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
    </article>
</xf:if>
 
So if you want the arctile layout for your add, it should look like this:

Position: Post: Below message container

Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==count($__globals.posts) - 2 AND count($__globals.posts)>2">
    <article class="message message--post">
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Before last post -->
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="xxx"
         data-ad-slot="xxx"
         data-ad-format="horizontal"
         data-full-width-responsive="false"></ins>
    <script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
    </article>
</xf:if>
And what about below first post.
Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==0">
    <div style="margin:-2px 0 28px 0;">
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- after 1st post -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="xxx"
     data-ad-slot="xxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
    </div>
</xf:if>
 
Pretty much the same...

Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==0">
    <article class="message message--post">
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- after 1st post -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="xxx"
     data-ad-slot="xxx"
     data-ad-format="horizontal"
     data-full-width-responsive="false">
</ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
    </article>
</xf:if>
 
Top Bottom