0

I am developing a webpage in Django in which contains two blocks of advertisements from Google AdSense. Before, I was serving this page using Apache2, but I switched to gunicorn + nginx due to it's extreme simplicity to configure and deploy the application.

Although the whole page works fine, for some reason now the ads are not showing up anymore. Thinking that the server switch may be the cause sounds a little bit without sense for me, as the AdSense code is a JavaScript loaded by the client, not by the server, but the server switch was the only change made in the page before they stopped to work.

nginx serves the page's static files directly at /static/, while the Django WSGI application is served by gunicorn, but binded to localhost port 8001, and then redirected by nginx to /.

The website is live at http://146.148.37.213/, if anyone is interested in checking the source code.

Here's my nginx site configuration:

server {
    server_name 146.148.37.213;
    access_log off;

    location /static/ {
        alias /var/www/Skorpius/static/;
    }

    location / {
        proxy_pass http://127.0.0.1:8001;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }

}
  • Do you have AdSense set to show public service ads when no other ads are available? If not, you should do so while you are testing your ad code and site layout. Often ads just don't show up because AdSense doesn't have any to show. This is a new site and you are running it on an IP address rather than a domain. Both of those will be factors that limit the number of advertisers available to you. – Stephen Ostermiller Mar 24 '15 at 15:10
1

The only way I the server change affects adsense is speed. If you switched to a server that performs slower than the last one, then you'll likely earn less or see irrelevant ads at best.

I couldn't use many of the various testing tools on your site because your URL is an IP address. Your first step is to change that IP address to an actual domain name so that google has something decent to list.

I tested your site both with firefox 15 and opera 11.6 web browsers, and when I loaded it in opera, a sidebar with terra servers or something appeared for a couple seconds then it disappeared. That can scare advertisers away because they will believe you're more interested in shifting their advertisements.

Luckily, I could test your page via webpagetest.org and your page loads differently for them, which perhaps is the way you wanted your page to load?

Also, you need to work on caching static content like external javascript pages, and compress images. See:

http://www.webpagetest.org/result/150324_D1_12BY/1/performance_optimization

Just remember, google runs with multiple IP addresses and could check your site from any of them. You want to deliver the correct page to everyone. and as for the source code, you might want to clean up the spaces and make it more compact and ditch the comment tags so that people on slow connections don't have to waste time downloading comments that they don't normally see.

Google also has similar results after tests. See:

https://developers.google.com/speed/pagespeed/insights/?url=146.148.37.213%2F

Google would pay you better if you try to make your site more mobile friendly as well.

And finally, condense the number of calls to external resources, especially if they're located on your server. For example, try to merge all javascript files to just one and use that.

As you can see, you have a lot of work to do in order to get some kind of quality ad on your website. Also, make sure you're not copying anyone else's content, and follow all recommendations by google and especially adsense policies.

  • That my friend, was a really good quality information you just provided me. Thanks for taking your time checking my page. About the multiple JavaScript files, they will be unified and minified later using Google Closure. Unfortunately the spaces are generated by Django's template system, but I can remove indentation so the code is more compact. Luckily, the UI framework (Material Design) is responsive, so hopefully I can cross mobile from my todo list. Anyway, thanks for your advises. :) – Bruno Finger Mar 24 '15 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.