matteocontrini This is excellent, thanks for sharing!

I made it work on my local installation but for some reason it is not loading the Google .js on my browser on the online version... I need one or two volunteers to try the dev version online!

Justoverclock xasharma

composer require malago/flarum-ads:dev-main

Thanks 😄

Actually I have no connection 😓waiting a fix from my provider but sure when I’m back I will try 🙂

I have tried each types of ads ... but i feel that Display ads are working better.

Good jobs @malago
I test in some weeks when my small community go live.

For future updates maybe a good idea some steps:

  • Working with roles to avoid the Ads for some users groups. Example: Premium members.
  • Some more places to add advertisements

Suggestion:

Ability to add Auto-Ad code the the Header for Google Adsense.

    After trying it for a few days I made the decision to push the fix to a new version. Version 0.3.2 adds a fix for the Adsense issue. I hope it works!

      MikeJones

      In my forum ... it shows the ads only 1 time.

      Let's take an example for the understanding - You are at the homepage of a forum and the ad should be visible under the header and under the tags (It barely shows header and footer ads on desktop... On mobile, it's better than the desktop). But it shows the ads only 1 or 2 times after that if we want to view the ads again we have to reload the page.

      And Now assume you opened a discussion and the ads should be after every 5 posts.
      So the problem with AdSense that it doesn't show any ads and it shows ads after refreshing the page 1-2 times and the same on mobile.

      And the second problem is that ... it shows the ads only 1 time 😅. I mean if you go back from that discussion and opened another one so it will not show any ad anywhere(header + under the tags+ between the posts) . We have to again reload the page 1-2 times to see the ads again. (Same with the mobile but better than desktop)

      I have tried simple banner test ads from some other networks .. they worked. It showed ads every ad and every time without any reload
      But then I tried google test ads from here - https://developers.google.com/publisher-tag/samples/display-test-ad ... It didn't work for me. It just makes space and sometimes it will show an ad.

      Maybe Adsense has some problem with SPA ?

      11 days later

      Is it possible to add the word "Advertisement" On top of each ad?

        Braden

        Like this ??

        <center>


        <center><div><h6>ADVERTISEMENT</h6></div>
        
        Your Ad code
          
        </center>

        Please, someone Review this is correct or not

          xasharma Good try! But if i place that before <script> it displays at the bottom

          It would have been nice if its at the top maybe inside ad div

            Braden

            For mobile -

            I also tried on google ads ... its working for me

            are you using auto ad code ??

              Braden

              Use display ad units ... these are better

              And use your ad auto ad code by installing an extension named HTML Head tags

              (You can also type your Adsense ID by Enabling in Flarum/ads but on 19th July google launched a new code so use the ad auto ad code in HTML head tag extension for better improvement because Flarum/ads use an older one which is also good but there is a mix of old and new code)

              you can read this article by google for more info - https://support.google.com/adsense/answer/10627874?hl=en

              How to use ad units?

              Go to your Adsense account and click on ads.

              Then choose by unit ads

              Personally, I use display ads for the whole site (you can try different if you want)

              Click on display ads and they will you a code snippet (ad code) and then use that ad code for between the posts under and for header + under tags)

              Your ad code will look like this -

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

              For Header use this code -

              <center><div><h6>ADVERTISEMENT</h6></div>
              
              Your Display ad unit code
                
              </center>

              For between the posts use this one -

              <center><div><h6>ADVERTISEMENT</h6></div></center>
              
              Your Display ad unit code

              For under the tags -

              <center><div><h6>ADVERTISEMENT</h6></div></center>
              
              Your Display ad unit code

                xasharma I now know why i was getting this problem

                You see these google codes, they can display "Advertisement" word automatic , its there, but its not shown on code. It can display automatic when the code is align at center in DIV ✔️

                i forgot to mention, with a css

                .google-auto-placed::before { 
                content: "Advertisements";
                }
                6 days later

                Since this extension asks for the Adesnse pub-xxxxxxxxxxxxxxxx

                Should I take it out of my ad code for them to display?

                I have this for under the header add and its not showing up

                <div align="center">
                <style type="text/css">
                .adslot_1 { width: 320px; height: 100px; }
                @media (min-width:500px) { .adslot_1 { width: 468px; height: 100px; } }
                @media (min-width:800px) { .adslot_1 { width: 728px; height: 100px; } }
                </style>
                <ins class="adsbygoogle adslot_1"
                    style="display:inline-block;"
                    data-ad-client="ca-pub-xxxxxxxxx"
                    data-ad-slot="xxxxxxxx"
                ></ins>
                </div>

                shoudl I remove the data-ad-client="ca-pub-xxxxxxxxx" line?

                Update, I tried removing that line and it didnt work. Not sure how to get the Adsense ads to show up here.