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. 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.

  2. 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.

  3. 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..

  4. 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.

  5. Теодор Савић Allow it sometime to get reflected..Also have you placed data-cfasync to right place (please check that as well)…For increased RAM theme and other settings (softwares installed as well) add up..I do not think rocketloader impacts RAM aspect (Have not tried or have any data in this support just a thought)

  6. Теодор Савић I used CloudFlare few months back..At that time using Rocket Loader would cause Adsense to think that visitor is coming from CloudFlare IP (RocketLoader loads them async from there servers)…So it will show ads relevant to that visitor (Geo targeted)..I also verified this by browsing my site..For this very reason I turned off Rocket Loader..Also it is grey area and I would not suggest to go that way..You can use Adsense Async code (in beta) to load ads async

Leave a Reply

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