How to (maybe) get WordPress Stats to accept the API key

WordPress stats is a nice little filter for WordPress, one of those devious hidden image IP trackers. Unfortunately, getting it to accept the API key doesn’t always work (even if it works for Akismet without complaint).

You may keep getting

Enter your WordPress.com API key to link this blog to your WordPress.com account. Be sure to use your own API key! Using any other key will lock you out of your stats.

even if the API key is correct. or if you hard code the API key

An API Key is present in the source code but it did not work.

The WordPress.com Stats Plugin is not working because it needs to be linked to a
WordPress.com account.

I didn’t find a solution in any of the forums, so I looked at the stupid script some more. Basically it uses the API key to get a “blog_id” (database index, most likely) from WordPress.com and can’t find one. So I made up a blog_id in the code. That shut up the plug-in, but of course stats aren’t tracked.

Finally, I went to http://dashboard.wordpress.com, logged into the account, made a new garbage *.Wordpress.com blog, then a bit later took out the made-up blog_id from the code, de-activated and re-activated, and … everything works. The external blog shows in the “Global dashboard.” Also the real blog_id is returned from code. But, if I take out the hard coded API key, it stops working again.

This is definitely a WordPress.com problem with registering externally hosted blogs, so to make it work, hard code the API key, make sure there is at least one *.Wordpress.com blog, wait a little bit, then re-activate the stats plug in.

Comments

  1. March 22nd, 2008 | 9:14

    can’t get it to work
    is there any other solutions?

  2. me
    March 24th, 2008 | 17:16

    Try de-activating and re-activating if you’ve already followed the steps in the last paragraph. That’s all I can think of.

  3. Thx
    July 6th, 2008 | 12:42

    Had the same problem. Thanks for posting.

  4. July 17th, 2008 | 3:20

    Hi,

    I got a problem finding my blog_id, could you describe how to find it more detailed?

    thx
    JMG

  5. September 10th, 2008 | 20:25

    Initially got this with 2.6.2 after hard coding the key in the file. I took it out of the file, re-activated the plugin and it asked for the key and that resolved my issue, because wordpress made me add my blog to an existing Wp.com account.

  6. September 1st, 2009 | 9:09

    i wish i know thaw the trouble so i can fix in my blog

  7. October 21st, 2012 | 23:48

    Youre so cool! I dont suppose Ive read anything like this before. So good to search out any individual with some authentic ideas on this subject. realy thanks for starting this up. this web site is something that is wanted on the internet, somebody with somewhat originality. useful job for bringing one thing new to the web!

Leave a reply