Google Adsense CloudFlare issue and solution

I have seen in my forums queries about drop in Google Adsense CTR after using CloudFlare.Many people do not use free content delivery network services of CloudFlare fearing drop in their Google Adsense earnings.

How Google Adsense works?

Google Adsense delivers ads based on
1.Content of your page (contextual)
2.Geographical area of visitor (Geo Targeted)
There are other ways to deliver matching ads on your webpage.But these two are related to this post.

How CloudFlare works?

CloudFlare works as reverse proxy.It stands between your website and the visitor.The static resources of your website (images,videos,css,js) gets loaded by CloudFlare.This is the way it makes your website fast.

How CloudFlare impacts Google Adsense?

As mentioned above CloudFlare stands between your website and visitor.So Google Adsense sees CloudFlare as traffic origin instead of the visitor.The ip address of CloudFlare server is visible instead of the visitor ip address. Due to this Google displays ads relevant to location of CloudFlare server instead of real visitor location.For example if original visitor is from India and CloudFlare server catering the request is in USA then visitor will see ads relevant to visitor of USA.

This wrong geo targeting of ads result in less CTR and hence less earning from Adsense.You can see ads in language other than English (assuming visitor is from English speaking region) CloudFlare server catering the request is in other region.


The solution approach is getting real ip address (that is ip address of visitors) instead of CloudFlare ip address.There are different approaches to do this depending upon web server you are using.Read this post for details of the solution for Apache web server and Nginx web server.

CloudFlare rocketloader issue with Adsense

RocketLoader is advanced asynchronous JavaScript loader.It can speed up website ten folds.But this loader is not compatible with Google Adsense.The reason is not very clear.But in my opinion RocketLoader loads the JavaScript from its servers.This is the very reason of incompatibility.
Below are the solutions in order of performance

Complex customization solution

In this method you need to set Rocket Loader mode to Manual.So the JavaScript code used on your website will not use this until and unless specified to do so.But this becomes complex if your JavaScript gets loaded from plugin like Disqus etc.In this method you can load compatible scripts using loader by specifying below command

first line of code before modification

<script type=”text/javascript”>

Above line should be changed to

<script data-cfasync=”true” type=”text/javascript”>

No customization solution

If you are not comfortable with above two methods then you can try this one.This method is the simplest but is worst in terms of performance.In this method you need to disable Rocket Loader by selecting Off.Thus your website will not be able to use benefit of this loader but you can still use free content delivery network facility of CloudFlare.

In case you have used any other method or having issues then please share your thoughts.

29 comments Google Adsense CloudFlare issue and solution

  1. Dart Tiglao says:

    turned off rocket loader and also installed the cloudflare wordpress plugin. adsense back to normal so far. Caveat: experimented on disabling that plugin and the whole site crashed. had to redo entire steps of configuring cloudflare for to revive site and after temporarily going back to origin nameservers.

  2. Good to know you got it working..thanks for sharing your experience

  3. Waqas Butt says:

    Thanks this will help me alot….my adsense is now performing well….:-)

    1. Esha Upadhyay says:

      good to know it is working for you

  4. Thank you so much for the post.
    Well said, Cloudflare erases all visitors history cookies and data. I setup cloudflare and now I no longer get visitors search terms in my Jetpack stats dashboard. because, I have used cloudflare Ddos protection.
    now, deactivated cloudflare’s optimization, Ddoes(security setting ) and tried to get relevant ads but didn’t work. will probably forget about Cloudflare and go back to my old hosting trouble of CPU resources limitations and bandwidths exhausted..

    1. Esha Upadhyay says:

      Security settings can be low and Rocket loader disabled..Also you need to install mod_cloudflare if using Apache or bypass CloudFlare ip’s on Nginx.

      1. Apnetv says:

        R u sure we can use cloudflare rocketloader enabled for google adsense ads. No risk? As google adsense policies says no modifications with ad code. Pls explain n reply

        1. Esha Upadhyay says:

          You can make it manual and make changes in JS files you want to load with rocketloader

  5. Hi sir,
    i used cloudflare for last 2 weeks for my website. i saw down trend in CPM of ads. Finally i decided today remove cloudflare and depend on hosting server.

    1. Esha Upadhyay says:

      Correct IP address was not passed to Google that’s why drop in CPM

  6. Amar Ilindra says:

    I’m facing same issue with MaxCDN. I noticed around 50% drop in adsense earnings with MaxCDN enabled. Do you know any solution for it?

    1. Esha Upadhyay says:

      I have not used MaxCDN so unable to comment.Do check if it is impacting Adsense ads in any way.Like is correct ip address being passed to adsense

  7. Hi,
    I have used Cloudflare about 5 days (disable Rocket loader, disable javascript minify), 2 days had no problem. But then my earnings were reduced by about 50 i disabled it for my blog. I think it is problem due to Cloudflare filter visiter ip address.

    1. Esha Upadhyay says:

      Are you using Apache or Nginx?

      1. Hi Esha, I am facing the same problem. Recently i switched to CloudFlare and I have seen a decrease in Google Adsense revenue. Rocket loader is disabled. The other solution to configure CloudFlare with Apache server work? Should I ask hosting to install mod_cloudflare? And what is Nginx?

        1. Esha Upadhyay says:

          Please follow the solutions mentioned in this post. It works. Nginx is web server and can be used instead of Apache

Leave a Reply

Your email address will not be published. Required fields are marked *