Piwik and Cloudflare

(karsh) #1


I have a wordpress site using Cloudflare, when using Piwik more than half the visits are not counted. I tried disabling Cloudflare and then the visits were counted correctly. Then I enabled it again and visits dropped immediately. GA and GetClicky counts fine either way. I have this in the config.ini.php file:

proxy_client_headers[] = "HTTP_CF_CONNECTING_IP"
proxy_client_headers[] = “HTTP_X_FORWARDED_FOR”

I also have set my nginx configuration as stated in the Cloudflare website.

What could be wrong?

(vipsoft) #2

Change the order that your trackers are loaded to see if it makes a difference.

Cloudflare has some anti-hacking blocker. Try turning it off.

(karsh) #3

I changed the order and even installed the piwik wordpress plugin and also tried turning security off in cloudflare but that didn’t make a difference.

But I found a solution. First was adding data-cfasync=“false” to the tracker code in the script tag, like:

<script data-cfasync="false" type="text/javascript" ... (twice in the code) Then adding a page rule with everything off for the directory where piwik is installed. In my case that was: *domain.com/analytics* http://i.imgur.com/96YTA.jpg Now it's working fine. :)

(vipsoft) #4

Thanks. I wasn’t aware of these settings. Cloudflare has changed quite a bit since I last looked at it.