Adsense cannot be used with Xojo Web

  1. 6 years ago

    Jay M

    28 Jan 2014 Pre-Release Testers, Xojo Pro Austin TX
    Edited 6 years ago

    I am wondering how to embed adsense into a Xojo Web app.

    There is a thread on the old forum that indicates that this is a fools errand.

    Anyone have a brilliant work around?

    Done it! :)

    I've been programming in Xojo for about a year and I've kinda left this final obstacle for later.
    Now that my website is almost complete I've spent about a month tinkering with AdSense before I succedeed.

    For starters, new Google's automatic vetting process is flawed. If you submit anything that fires up .cgi you will fail. I should know, I've tried it several times with .cgi, full page frame pages with redirects and whatever else I could think of. Their 3 days waiting period often stretched to 8-10 days. Therefore my attempts were days apart.

    Finally I've decided to game the system. I've placed a flat html index page with some semi-related content (no cms, links or whatever) and voilla, I was AdSense worthy in a day. Then I've changed the index.html <head> like this:

    <head>
    <meta id="redirect" http-equiv="refresh" content="0; url=http://mydomain/myfolder/myapp.cgi">
    </head>

    And In my Xojo App I use a weblabel (with fixed size else anchored on two points - or else I got smaller adsense unit shown then the desired weblabel size) that opens an iframe (for the ease of testing - this way I could change my adsense related code without recompiling):

    mylabel.text = "<raw><p><iframe frameborder=""0"" width=""250px"" min-height=""600px"" height=""650px"" src=""adse.html""></iframe></p></raw>"

    Notice the relative path - doesnt work without it. My adse.html file is in a a folder where my .cgi app is. If you use hashtags with /# instead of just # frame will not load beacause of relative paths. Also size is vertical beacuse I needed vertical banners for the sides of my website.

    Contens of my adse.html is a gener AdSense generated code:

    <body>
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- my_ad_unit -->
    <ins class="adsbygoogle"
         style="display:inline-block;width:160px;height:600px"
         data-ad-client="ca-pub-xxx"
         data-ad-slot="xxx"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    </body>

    I load it in my resized event (Unsure if this is the best way).
    It works nicely, pageviews andimpressions are shown and calculated just as well as on any other website.

    I work on my AdBlock detection now.

    Hope that was clear enough. Good luck, and now that people know it could be done I expect refinements and a better way of doing AdSense.

  2. Greg O

    28 Jan 2014 Xojo Inc scout.galaxy.barn

    Do you happen to have a link to the API docs? I can't seem to get to them without signing up for an account.

  3. Rick A

    28 Jan 2014 Pre-Release Testers (Brazil. GMT-3:00)

    You will need a test account anyways, just to check that your experiments works. It costs nothing. :)

    The API's entry page is here: https://developers.google.com/adsense/

    As for an account creation, go here: https://www.google.com/adsense?hl=en&sourceid=aso&subid=ww-en-et-api&medium=et

  4. 2 years ago

    ronaldo f

    18 Dec 2017 Pre-Release Testers, Xojo Pro Philippines

    Anybody had succeeded working with google ad-sense?

    Hoping that this will be revived.

  5. 3 months ago

    Vitomir S

    Aug 6 Answer

    Done it! :)

    I've been programming in Xojo for about a year and I've kinda left this final obstacle for later.
    Now that my website is almost complete I've spent about a month tinkering with AdSense before I succedeed.

    For starters, new Google's automatic vetting process is flawed. If you submit anything that fires up .cgi you will fail. I should know, I've tried it several times with .cgi, full page frame pages with redirects and whatever else I could think of. Their 3 days waiting period often stretched to 8-10 days. Therefore my attempts were days apart.

    Finally I've decided to game the system. I've placed a flat html index page with some semi-related content (no cms, links or whatever) and voilla, I was AdSense worthy in a day. Then I've changed the index.html <head> like this:

    <head>
    <meta id="redirect" http-equiv="refresh" content="0; url=http://mydomain/myfolder/myapp.cgi">
    </head>

    And In my Xojo App I use a weblabel (with fixed size else anchored on two points - or else I got smaller adsense unit shown then the desired weblabel size) that opens an iframe (for the ease of testing - this way I could change my adsense related code without recompiling):

    mylabel.text = "<raw><p><iframe frameborder=""0"" width=""250px"" min-height=""600px"" height=""650px"" src=""adse.html""></iframe></p></raw>"

    Notice the relative path - doesnt work without it. My adse.html file is in a a folder where my .cgi app is. If you use hashtags with /# instead of just # frame will not load beacause of relative paths. Also size is vertical beacuse I needed vertical banners for the sides of my website.

    Contens of my adse.html is a gener AdSense generated code:

    <body>
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- my_ad_unit -->
    <ins class="adsbygoogle"
         style="display:inline-block;width:160px;height:600px"
         data-ad-client="ca-pub-xxx"
         data-ad-slot="xxx"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    </body>

    I load it in my resized event (Unsure if this is the best way).
    It works nicely, pageviews andimpressions are shown and calculated just as well as on any other website.

    I work on my AdBlock detection now.

    Hope that was clear enough. Good luck, and now that people know it could be done I expect refinements and a better way of doing AdSense.

  6. 5 weeks ago

    Changed my iframe loading code for AdSense to this iframe replacement code:

    mylabel.text = "<raw><p><object data=""adse.html"" type=""text/html""></object></p></raw>"

    All standard width, height, frameborder and any other properties may be used, ofc.

    According to what I've read this method will not block onload event, and, according to my limited testing - whole page loads quite a bit faster while AdSense works flawlessly.

  7. 9 hours ago

    Jay M

    9 hours ago Pre-Release Testers, Xojo Pro Austin TX

    @Vitomir S Thanks. After 5 years my question is answered! I just hope that web 2.0 wont break it!

  8. 8 hours ago

    Norman P

    8 hours ago Pre-Release Testers, Xojo Pro great-white-software.com/blog
    Edited 8 hours ago

    Web 2.0 is a complete rewrite
    Xojo has said this several times
    So the likelihood you will be able to keep your existing code without changes is low
    And that means you may have to solve this issue once again when Web 2.0 ships

or Sign Up to reply!