Google Analytics

Google just announced that they are going to providing another service, called Google Analytics. The new service allows webmasters to have free web stats based on Google’s prior Urchin Stats service. All you have to do is signup with Google on their Google Analytics site, and signin using your Gmail, Adsense, or Adwords account.

Once you go through the signup process, you get a simple javascript to add to your html pages.

For WordPress users dt’s Blog.thedt.net site has a Google analytics plugin that gives you a simple text box for you to paste the script code into. I had to correct the plugin code, because for some reason it stripped out the php lines, so if you cannot correct the code from dt’s site, feel free to copy the Google Analytics plugin code from our WordPress forum.

Another WordPress plugin that is easier to use is Cavemonkey50’s Google Analyticator plugin. Unlike dt’s plugin, Analyticator just asks you for the user account code, and not the entire script.

However how does Google Analytics compete against the other web stats packages out there, well Eric Peterson gives us some of his thoughts on Google giving away web stats.

Flushing DNS Lookups

Every now and then I run into a situation where I need to clear my DNS cache. This is sometimes needed when there are negative DNS values, meaning incorrect IP addresses on my computer for certain internet sites that I want to connect to. You can use the following commands to flush DNS and see if this allows you to reach the site.

Mac OS X:

For OS X, Lookupd takes care of cached DNS entries. You will need to open a Terminal session and type the following command:

lookupd -flushcache

On Mac OS X 10.5 Leopard, you no longer have the lookupd command. Use the dscacheutil command instead:

dscacheutil -flushcache

Windows:

For Windows, the IPConfig utility serves as an easy way to view TCP/IP settings and as a utility to flush DNS. You will need to open up a prompt and type the following command:

ipconfig /flushdns

Windows2000 & XP save negative DNS entries by default, so you might want to try disabling negative DNS caching to get a more responsive internet connection.

Microsoft has some notes on DNS settings in Windows too that you can reference.

Custom Shortstat Plugin

A very handy plugin that I use for web stats is Jeff Minard’s WordPress port of Shortstat, which is a script that Shaun Inman originally wrote.

Shortstat Plugin Conflict

It appears that Jeff recently updated the Shortstat plugin to version 1.3 and that there was a conflict with another great plugin, Google Sitemap Generator. After some research on WebKeyDesign, I found that the 2.7 version of Google Sitemap Generator conflicts with the 1.3 version of the Shortstat plugin. But the 2.7.1 version works fine. If you have not updated Sitemap to 2.7.1, first do that then download the new 1.3 version of Shortstat and set that up. This should make both plugins work.

Shortstat Slows Down WordPress Dashboard

As if the Dashboard was not slow enough some days, Shortstat adds even more delay due to the IP address lookup that it does. You can disable this feature if you do not particularly care about what country your visitors are from. Most webmasters want to know what state or region in the USA, instead of the country, so for many webmasters this feature is not specific enough. To disable the feature just go to line 119 and look for the following code:

$coinfo = @file('http://www.hostip.info/api/get.html?ip=' . $ip);
$country_string = explode(':',$coinfo[0]);
$country = trim($country_string[1]);

Change the code to this:

// $coinfo = @file('http://www.hostip.info/api/get.html?ip=' . $ip);
// $country_string = explode(':',$coinfo[0]);
// $country = trim($country_string[1]);
$country = '(Private Address) (XX)';

The Dashboard will still be slow due to feeds but Shortstat will not add to the delay.

Shortstat Database Data

If you take a quick look at the stats that you get, you can tell that they can start to add up and that while these stats are adequate for a quick daily glance, they are not really something to keep for a year or even more than a few months, so what you eventually need to do is zap the stats from time to time.

Shortstat adds two tables to the WordPress database: ss_stats and ss_search. I personally zap ss_stats more often than ss_search, since ss_search has the data for sites that refer to me and what searches people have used on my weblog. You can however zap both tables. If you have your log hosted on cPanel or have access to just phpMyAdmin you can easily do this. You will need to select only the two tables, and none of the other tables or you could end up deleting your blog data!!! Make sure you backup first. You can reference my Optimize Your MySQL Databases instructions, which should help you understand the process a bit better. The only difference is that instead of optimizing the table, you will be choosing to empty the selected table.

Shortstat in Blue

One last thing that I like to do with Shortstat is change the color design. For some reason the red links really bother me, but since I started changing it I ended up adding color to the columns too. Here is kind of what it looks like in blue:

Shortstat Plugin in Blue

Custom 1.3 Shortstat Plugin

If you like the blue scheme and want to disable the IP lookup feature, you can download the plugin with the complete changes here:

wpshortstat.blue.txt

You can copy and paste the code into the Plugin Editor or rename the file to wp-shortstat.php and upload it to your server.

Custom Shortstat Plugin for WordPress 2.0

Since WordPress 2.0 came out I redid the changes, see WordPress 2.0 Shortstat Plugin.