XF 2.2 How-to Adsense on XF 2.2

Oh sweet, that's nice this stuff is built in already.

Do you know if Auto Ads is supported so that one piece of code generates ads throughout where it would make sense?
I think so. I tried auto ads and it seemed to show where it wanted to. But I didn't like it so went back to regular.
 
So just to clarify. Does this mean that I go to: Setup > Advertising > Add Advertisement

And place this code into the HTML box?

Code:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456"
       crossorigin="anonymous"></script>

And then an ad should show up in the position I chose?
 
So just to clarify. Does this mean that I go to: Setup > Advertising > Add Advertisement

And place this code into the HTML box?

Code:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456"
       crossorigin="anonymous"></script>

And then an ad should show up in the position I chose?
That code belongs in the PAGE_CONTAINER template.

Each individual ad position you make will then have it's own code that will be placed in the HTML section under Setup -> Advertising.

If you use "Auto Ads" (not recommended for forums, or any site with complicated layouts), the Auto Ads will automatically start showing with just the above code in the PAGE_CONTAINER template.
 
So just to clarify. Does this mean that I go to: Setup > Advertising > Add Advertisement

And place this code into the HTML box?

Code:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456"
       crossorigin="anonymous"></script>

And then an ad should show up in the position I chose?
You should not use automatic advertising
 
I also have @AndyB addon called ad manager

Does anyone know how that addon compliments, differs, or replicates, the same functions of Xenforo's native ad setup?

I'm a bit hesitant to mess with the PAGE_CONTAINER templates if there is another way of doing it.

All I want to do it:
  • use google adsense
  • place an ad
    • Container content: Above
    • Container sidebar: Below (maybe)
Nothing else. No "Auto Ads" or anything else that messes up the site.

Thanks.
 
That code belongs in the PAGE_CONTAINER template.

Each individual ad position you make will then have it's own code that will be placed in the HTML section under Setup -> Advertising.

If you use "Auto Ads" (not recommended for forums, or any site with complicated layouts), the Auto Ads will automatically start showing with just the above code in the PAGE_CONTAINER template.

Sorry, I'm a bit confused. Is that script used for Auto Ads only, or do I still need to use it and place it in the PAGE_CONTAINER if I only want to use Manual Ads (via the ACP)? Thanks.
 
Yes I did. It says place the script in helper_js_global. While the person above said place it in PAGE_CONTAINER.

So that's already different.

Second, I was asking if that script was needed for Manual Ads, as it seems to be associated with Auto ads (which I didn't want)

Thanks.
 
Last edited:
You need that script for manual ads as well as auto ads.

The code can go in the page_container or helper_js_global. I don't use Adsense anymore, but I had a template modification that loaded it into the page_container - just as long as you have it loading before any ad positions, you are good.


This is your standard adsense ad unit code:-

HTML:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXX"
     crossorigin="anonymous"></script>
<!-- ADSLOT NAME -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-XXXXXXXXXXXX"
     data-ad-slot="XXXXXXXXXXX"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

The bit at the top only needs loading once on the page
HTML:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXX"     crossorigin="anonymous"></script>

So once you have that placed in your page_container or helper_js_global, you need to ad the last bit of code under the adslot name in your ad position via the advertising section in the admincp

1719211030393.webp
 
Back
Top Bottom