Forums

Can I implement AdSense in my Python App under free PythonAnywhere account?

Hi there,

I am trying to paste AdSense code in my Python App. But its not working. Any clues??? I have a free account with PythonAnywhere.

Thanks.

Are you seeing any particular error when you say that it is not working?

Thanks Conrad, No, I am not seeing any error. Just blank space, as if the ad is invisible.

Hm. Maybe talk to Google, see if they have some ideas? We're not really experts on AdSense here...

I am having this problem as well, were you able to get this figured out? I just set up my web app and the adsense worked when running on localhost but not on python anywhere.

My hope was that I could get enough traffic going that adsense could help pay for a monthly membership.

Check the developer tools in your browser. There may be errors there that show you what's going wrong.

As it turns out Google Adsense is banned from the PythonAnywhere Domain. They don't want their ads on test websites.

oh. is that documented anywhere? or is that something you heard from Google support directly?

I saw it here: https://github.com/FrozenSquirrels/polyglot/issues/26

That's got nothing to do with PythonAnywhere directly, it has to do with using non-www subdomains (which Google don't like for some reason) That means that username.pythonanywhere.com will not be allowed, but a custom domain will (as long as it either doesn't have a subdomain or uses www)

Subdomain is not allowed you need to shift to a proper domain How did he get the code in the first place ? was subdomaine allowed 2 years ago?

How did he get the code in the first place ? was subdomaine allowed 2 years ago?

No, I think it was just never allowed -- that's why this forum topic started.

hey Giles and MTS2, I think either subdomain was allowed 2 years back that's how he got the ad-embed code or he registered with some other "domain" and by the time he started using it here, Google changed their policies and he ended up with a bunch of alphanumeric text.

I have adsense running on github (username.github.io). So that's is strange. But adsense is refusing to test my site in pythonanywhere because it needs a "higher level domain", e.g. pythonanywhere.com

hmm, in that case it does seem like you will need to use your own custom domain on pythonanywhere to get it to work.

I have custom domian on pythonanywhere but adsense still does not work - they have not approved the site not due anything weird reason, just technical. What could be the reason?

Maybe: they need naked domain https://example.com instead of https://www.example.com - mine is https://www.example.com. naked domain does not work.

Or DNS issue - but I dont know how to test or verify this.

We have no special way of knowing why AdSense is not approving your site. You will need to contact AdSense to determine that.

I have been unable to point domain.com/ads.txt to https://www.domain.com/ads.txt. Am I missing something? I use NameCheap for my DNS and they have said they can do nothing to solve this on their end.

Is the ads.txt a domain verification thing from Google AdSense? If so, how have you set your site up there -- could you not configure it to be www.yourdomain.com instead of yourdomain.com?

It is for Google Adsense. They explicitly say that they only check https://domain.com/ads.txt. I asked if it's possible jo just provide the full link and they said no.

That's a strange choice on their side! I think that the best bet would be to switch from using NameCheap's domain redirect to using Cloudflare, then -- you won't need to move your domain over, that would remain with NameCheap, but Cloudflare can do domain redirection with extra features like being able to handle specific URLs differently. You'd point the "naked" domain to them, and then set up a page rule to handle the redirection.

That's what I was asking namecheap to do -- I could handle the reroute myself if I could receive the <extra< portion from domain.com/<extra> but they said they can't do that. So I would just have to pay Cloudflare for advanced redirection features?

Right now I have the CNAME mapped to PythonAnywhere, would I have to change that to Cloudflare? Or would I only have to use their more advanced rerouting features for the naked path?

EDIT: I figured it out. If anyone else every has the same issue, NameCheap has instructions on how to point to CloudFlare as a nameserver and use better redirects:

https://www.namecheap.com/support/knowledgebase/article.aspx/9607/2210/how-to-set-up-dns-records-for-your-domain-in-cloudflare-account/

Excellent, glad to hear you worked it out! From what I understand, you should be able to do that in a free Cloudflare account, or at least that was the case a while back -- is that still correct?

Yes it is still the case. PythonAnywhere is having issues with my CNAME record -- is this caused by a propagation delay from switching to CloudFlare?

Ah, sorry, I should have said. If you're using Cloudflare to manage your CNAME record, it will hide the true value of the record from other servers on the Internet -- including ours. So you will always see a warning in the DNS section of the "Web" page. That can be ignored.

But my site doesn't load at all so is that just a delay from the DNS transfer? Does that also apply to the site https://www.whatsmydns.net/ -- will the CNAME never propagate? Forgive my ignorance, I don't really know much about web servers.

I think this will be easier for us to help you with if we can see the setup that you've done on the Cloudflare side, and it's probably best not to make that public in case there's private information there; could you email a screenshot of your configuration to support@pythonanywhere.com, with a link to this forum thread so that we have the context?