Vanilla Forum “Statistics Permission denied” Error

Recently, I installed Vanilla Forum on one of my sites. Overall, Vanilla Forum is a clean and fast community type forum platform. But there was one issue bugging me for a while. That is the error message of “Analytics: Permission denied – Verification is required, but failed.” pops up on the lower left hand side of the page from time to time. I Googled it, and did find some threads talking about this issues from Vanilla Forum Community. But it seems no one had given a clear answer.

I spent some time to look into the source code, and finally figured out the solution. In short, just need to disable Vanilla Statistics by adding the following line into your installation’s configuration file (conf/config.php):

$Configuration['Garden']['Analytics']['Enabled'] = FALSE;

Is it just that easy? Yes it is. The following are why make it so hard to me,

First, I could not find error string “Permission denied – Verification is required, but failed.” anywhere in the source code, so I did not know where to start to debug this. Finally I found they are using the stand way to show information message on the left lower corner, by which I found this,

 "Gdn::Controller()->InformMessage("Analytics: {$Reason}"); 

in library/core/class.statistics.php. From there, I figured out the error because the registration of Vanilla Forum Statistics failed. The message is from Json Response, that’s why I could not find it in the source code.

Secondly, someone actually mentioned the Vanilla Statistics, but I thought I did not enable it. There are actually two Statistics, one is in the Core (Garden), and the other one is in the Plugins. Not sure if they are the same thing, but one thing for sure is that disabling the plugin one does not turn off the Vanilla Statistics. You have to manually add the above line into your installation’s configuration file. (Looks like they really want us to use this feature.)

Furthermore, someone mentioned that the curl-exec is not enabled. I think this is a misleading. Because, based on source code (library/core/functions.general.php), if it’s curl issue, you will not see “Permission denied – Verification is required, but failed.”, instead see “Encountered an error while making a request to the remote server: Your PHP configuration does not allow curl or fsock requests.”

Finally, I still have not figured out why I cannot register Vanilla API. Is Key wrong? Anyway, I can use Google Analytics instead if I really want.