Some people prefer to maintain privately hosted WordPress installation than using WordPress.com because you have more control and freedom using a privately hosted WordPress blog. However, there are certain features that you have to unlock or activate using a WordPress.com account such as WordPress.com Stats and Akismet.
Today, I tried to change the API key that I am using for my blog because I recently restructured my blog and cleaned things up. I couldn’t remember how or when did WordPress.com started merging Gravatar accounts. I was confused and now I have two API keys for two WordPress.com accounts but I have activated my WordPress Stats using the wrong account. Yeah, I know it is confusing, but to get to the point, I have to change the WordPress API key I used for the stats, and also with Akismet.
The instruction found in WordPress.com support is helpful to a certain extent. You can go and check how to change the API up to step #6.
After doing step #6 however, I didn’t get the “Please enter an API key” warning but I went through and disabled the plugin and reactivating it again. Clicking WordPress.com Stats from the admin menu didn’t prompt me to change the API key. It just tells me that user “xxxx” is not authorized to view the stats of this blog.
At this point I didn’t know what I have done wrong because I followed the steps correctly. If you have the same problem take note that you have to follow steps #1 to #6 on how to change the API key before you proceed here.
I thought that If the API setting is not in custom configuration, it must be in the database. It must be.
So I used phpMyAdmin to search my WordPress tables for keywords like “%API%” (with wildcard) and I found several entries. You should be interested in wp_options table where you can find stats_options entry under option_name field and you should only edit the option_value entry. Check the screenshot below for reference:
You should see the old API key. Change that with the new one, then save it. That’s all you have to do here. After that, go to the admin menu, click Site Stats and you should be able to view your website’s statistics already.
I hope this helps. If it doesn’t work, you can always contact WordPress.com support.