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.

Solution

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. Please follow the solutions mentioned in this post. It works. Nginx is web server and can be used instead of Apache

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

  3. 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 percent.so i disabled it for my blog. I think it is problem due to Cloudflare filter visiter ip address.

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

  5. Hai
    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?
    Thanks

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

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

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

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

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

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

  12. Теодор Савић 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)

  13. Теодор Савић 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

  14. Esha Upadhyay Hey, you were right. I tweaked CloudFlare a lot these days and I cleaned cache every now and then so I didn't notice that, but when you let it work for some time it (i suppose) caches all adsense ads and earnings start to drop down significantly. I disabled Rocket Loader for now. Disabling it decreased my websites performance and I also noticed that now the website takes a lot more RAM memory (arround 3 times more with approximately the same number of people online and pageviews). I'm not actually sure how could I still use Rocket Loader for other javascript. I used notepad++ to scan the entire website searching for <script and then I manually added data-cfasync to external javascript queries and it took me the whole day but still YSlow registered no improvements.. :/

  15. please do not get confused by style-sheet and JavaScript files…You should only add data-cfasync to every external JS files (not internal ones)..External JS files like Facebook social widget codes and any other codes your site might be using..Do not edit Adsense tags this does not work…Do let me know in case of any issues

  16. Esha Upadhyay I tried editing everything manually but with no success. I got the same YSlow grade as if I didn't do anything. When I set Rocket Loader to automatic I get 12 points more. I just can't directly see what is the difference in AdSense revenue between turning Rocket Loader on and off. I turned off Rocket Loader and I got the same CTR and CPC as when it was on. To make things worse, I got less ad views comparing to pageviews with Rocket Loader off so I'm not exactly sure why should I do this customization. If using Rocket Script violates AdSense terms than it would be a good reason to turn it off or set it to manual but until now, I only benefited from using Rocket Loader. Is someone having a different experience with this?

  17. Hi!
    I have a question regarding RocketLoader solution. Are you saying that I need to edit all javascript on my website (besides Adsense) by adding data-cfasync=”true”? It seems a little impossible since e.g. in WordPress there are dozens or even hundreds of stylesheets. The solution that Gustavo gave is much simpler and it might work but adsense strictly forbids changing their ad tags so I wouldn't play with it.

  18. CloudFlare IP address is visible to Google Adsense but not visitor IP address as CloudFlare works as reverse proxy

  19. How is it that IP address of visitor is cloaked by CloudFlare? Regardless of where visitor comes from, he always must carry his IP.

  20. do you have approved adsense account..please provide more details so that i can help you

  21. Yes it is a solution..but I would recommend not to use it with Adsense..I have some weird ads displayed using this with adsense..but for other cases it works fine

  22. Another solution:

    You can have Rocket Loader ignore individual scripts by putting this tag before the script:

    <script data-cfasync="false" src="/javascript.js"></script>.

Leave a Reply

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