Tips, Tricks, Tools & Techniques

for Internet Business, Life, the Universe and Everything

RSS Feed



Category: WordPress

How to install a web analytics tool the right way

28 September, 2007 (13:20) | Testing, Tools, WordPress | By: Nick Dalton

Welcome to the first installment in the Tracking, Testing and Tweaking Your Web Site series. If you haven’t yet suggested topics you’d like to see covered in the future, it’s not too late to do so.

In this first article I’m going to cover installing a web analytics program for your web site. This is the first tool that you should to get into place to track your visitors. Even if you’re already using Google Analytics or a similar tool, please read on as there are some important tips in this article that will help you later on.

Web Analytics Tools

Your web hosting account probably came with a web statistics tool like Webalizer or AWstats. These tools can show you some statistics about your visitors and their page views, but they do not track visitor behavior very well. So ignore those tools.

The “installation” of most modern web analytics programs consist of adding a little piece of JavaScript code to each web page on your site. Since this code needs to go on every page most vendors recommend that you place it in the footer of your site (assuming that you have a footer file that is included on all web pages). There is another reason for placing the code at the end of the page: The JavaScript code takes some time to execute and if it’s at the bottom of the page the visitor will be able to view and read the full web page while the browser is processing the web analytics JavaScript. However if you want to do some more advanced web analytics, installing the JavaScript at the end of the page is sometimes the wrong thing to do. More about that later.

I suggest you use two different web analytics tools: one simple tool for real time information and another one for more advanced analytics. Real time information can be useful to react to abnormal traffic. For example: Last week one of my old blog posts became popular on StumbleUpon and I received over 500 visitors within a few hours. While it was a good blog post, it didn’t have any affiliate links. So I quickly added a few to capitalize on the traffic surge.

There are many, many web analytics tools to chose from. The simple tools have similar basic web analytics features and offer detailed data on the last 100 – 500 page views for free. If you want a larger buffer you have to pay a monthly fee. (Obviously if you’re receiving 10,000 page views per day then 500 is only going to last you an hour or so which is probably not all that useful.) The advantage with these simple tools is that the data is shown practically in real time. You can literally follow along as visitors are surfing your site. Not that this is good use of your time…

StatCounter

The simple web analytics tool that I use is StatCounter. Sign up for a free account and then answer a few questions about your site. Of these questions there are a few that are significant: Make sure that you add your own IP address to the IP Blocking section so that your own page views on the site are not included in the stats. StatCounter helpfully displays your current IP address next to the entry window, e.g. 76.81.54.162. If your ISP doesn’t give you a static IP address you can block out a whole range of addresses with a * at the end (76.81.54.*). If you still see your own traffic occasionally you might consider blocking an even larger range (76.81.*.*).

The other important configuration with StatCounter is the look of the “counter”. In the early days of the web it was cool to display a counter on your web pages to show how popular your site was. For a business web site this looks very unprofessional, so you should be sure to select the “Invisible” counter.

After all the questions are answered you will get a snippet of JavaScript code to install on your web site. It will look something like this:
<!-- StatCounter -->
<script type="text/javascript">
var sc_project=xxxxxxx;
var sc_invisible=0;
var sc_partition=29;
var sc_security="xxxxxxxxx";
</script>
<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c30.statcounter.com/xxxxxxx/0/xxxxxxxx/0/" alt="website stats" /></a></div></noscript>

This JavaScript code should be added just before the </body> tag at the end of each of your web pages. If you’re using WordPress, the file to edit is called footer.php within the Theme you have selected for your blog. After you have added the code, do a View Source with your browser to make sure that it was installed correctly. If you do a View Source on this web page and scroll down to the bottom you will see what it should look like. Also with the real time nature of StatCounter you should quickly start seeing traffic statistics in the tool.

Google Analytics

The other web analytics tool that I use is Google Analytics. It is pretty advanced and you can’t beat the price: free. (You may have to sign up for a Google AdWords account to use Google Analytics, which may require a $5 activation fee. But there is no requirement to actually spend money on AdWords to use Google Analytics.)

In Google Analytics you should also block your own IP address. This is done in Analytics Settings -> Profile Settings -> Add Filter. Select Filter Type “Exclude all traffic from an IP address” and then enter your IP in this format: 76\.81\.54\.162 (Google uses powerful regular expressions here, hence the backslashes in front of each dot. Click on the help link for more information.)

I recommend that you place the Google Analytics JavaScript code in the <head> section of your web pages. This may seem counter to what I said above. But GA offers a feature called urchinTracker that allows you to track outbound links, among other things. To use urchinTracker the GA tracking code must be placed before any links or events that try to call it. The <head> section is a good place to ensure this.

For WordPress users the file to edit for the <head> section is header.php. If you’re not comfortable editing PHP files then there are several WordPress plugins that make it easier to install web analytics tracking code. Just make sure you get a plugin that allows you to control where on the page the code is added.

Again View Source on this page to see what the completed installation should look like.

That completes the installation of your web analytics tools. I know this was a very brief tutorial, so if there is enough interest I may create a Camtasia video to illustrate each step.

Customize your BlogRush widget with this WordPress plugin

28 September, 2007 (00:15) | Tools, WordPress | By: Nick Dalton

This post used to contain a nice description of a new WordPress plugin that I wrote. The plugin allowed you to completely change the style of the BlogRush widget by supplying your own stylesheet. With this feature it’s much easier to get the BlogRush widget to blend in to the style of your blog. However John Reese made a good point that if each blog customizes the look of the BlogRush widget, click through rates may vary wildly throughout the system. Therefore John requested that I take down the original post and the link to my plugin.

This is not the first nor will it be the last useful/controversial WordPress plugin I’m developing. So stay tuned! (A good way to do that is to subscribe to the RSS feed or to the email notifications for this blog.)

Database backups

9 September, 2007 (01:22) | Security, Tools, WordPress | By: Nick Dalton

Databases cannot be backed up as regular files because the database continuously writes to its files, so you are very likely to backup an incomplete or corrupt set of files. Therefore you need to use a special database backup program to create the backup. After the backup program has done its job you can then copy, move and archive the backup files just like any ordinary file.

Most web server control panels come with a database administration program. A popular option is phpMyAdmin for MySQL databases and phpPgAdmin for Postgres. Here are step by step backup instructions for some of the more popular control panels. And equally important: restore instructions.

The drawback with these database administration programs is that you have to perform the backup manually. If you’re like most people you will put off a manual chore like this until it’s too late. Therefore the goal should always be to automate your backups. If you’re running a WordPress blog on your web site you should definitely install the excellent WordPress Database Backup plugin. This plugin used to be distributed with WordPress 2.0 but was later mysteriously dropped from the standard distribution. If you have other programs on your web site that store information in a MySQL database then you need a full backup script like AutoMySQLBackup. Note that this latter solution requires some Linux shell knowledge to setup.

A great feature of both the WordPress Database Backup plugin and AutoMySQLBackup is the ability to email the backup files to yourself every day. I recommend that you setup a new Google Gmail account which has over 2 GB of storage to receive your backup files. Unless you’re a very prolific blogger, 2 GB should last you for quite a while. Then once a month or so you can login to the email account and delete old files.

Just like with regular backups is critical that you test your restore procedure occasionally. For this you can install MySQL or Postgres locally on your PC and restore the data to it. Backup files typically contain checksums and integrity checks, so if the file restores without errors then it’s very likely that the restore was successful without you having to verify the contents of all the data.

Now go back something up!

WordPress behind a firewall

30 August, 2007 (16:21) | WordPress | By: Nick Dalton

Later versions of WordPress has a tendency to talk to itself. This is not a sign of loneliness, but rather an efficient design for trackbacks, pings and other asynchronous events. After you publish a post, or at a predetermined time for a future posts, WordPress sends a URL request to itself. Normally this works as designed and is totally transparent to the blog owner. But with some firewall configurations this mechanism fails.

In a simple web server setup your domain name resolves to the IP address of the web server.
$ nslookup www.yourdomain.com
Name: www.yourdomain.com
Address: 217.68.70.69
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:30:1B:43:85:7F
inet addr:217.68.70.69 Bcast:217.68.70.255 Mask:255.255.255.0

But with a firewall or a load balancer in front of the web server the domain name resolves to the IP of the firewall (or load balancer) which then forwards requests to the web server.
$ nslookup www.otherdomain.com
Name: www.otherdomain.com
Address: 64.27.14.2
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:30:1B:43:85:7F
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0

With a firewall you need to explicitly permit traffic for each source and destination. The default configuration for a Cisco PIX firewall for one major hosting company allows web traffic from the outside world through to the web server, but the default rules prevent any traffic from internal servers to internal servers. This is generally a good setup. However, this creates a problem when WordPress tries to access a URL on its own domain. The domain name resolves to the firewall, so the request is sent from the web server to the firewall. The firewall realizes that the request is coming from an internal server so it blocks it.
$ wget www.otherdomain.com/index.php
--21:43:11-- http://www.otherdomain.com/index.php
=> `index.php'
Resolving www.otherdomain.com... 64.27.14.2
Connecting to www.otherdomain.com|64.27.14.2|:80...
^C

There are at least two ways to resolve this problem:

1. Create a new rule in the firewall that allows traffic from the IP address of the web server to itself.

If you don’t have access to the firewall configuration or you don’t want to mess with the rules, then another option is:

2. Add a line to /etc/hosts for each domain served by the web server:
10.0.0.1 www.otherdomain.com

There is a slight performance benefit to this latter approach since requests don’t have to go through the firewall. The drawback is that you have to remember to add a line to /etc/hosts for each new domain.

As far as I can determine WordPress does not show any error messages for the trackbacks and pings that fail. My blog was broken in this regard until I figured this out. And I just thought that other bloggers were ignoring or deleting my trackbacks. :-(

It also turns out that WordPress queues all the failed pings and trackbacks. So if you suddenly received a trackback to your blog from an old post here, that’s the reason why.

Update to WordPress 2.2.2

6 August, 2007 (21:55) | Security, WordPress | By: Nick Dalton

If you are using WordPress 2.2.1 you should immediately get the 2.2.2 security update.

The discovered bug is a Cross-Site Scripting vulnerability. See http://trac.wordpress.org/ticket/4689 for more details.

The WordPress developers assigned this bug a priority of “highest omg bbq” :-)

Upgrading WordPress to a new point version

22 March, 2007 (17:16) | WordPress | By: Nick Dalton

Upgrading WordPress is easy and follows almost the same procedure as when initially installing WordPress. I recorded step by step instructions in a video.

Isn’t there an easier way to install WordPress?

9 March, 2007 (12:43) | WordPress | By: Nick Dalton

Installing software on a Linux server is often way beyond beginner level. Even WordPress with its famous 5 minute installation requires you to create a MySQL database, a database user, assign permissions, and edit a configuration file. It’s not rocket science and if you follow my WordPress Installation Tutorial it’s just a matter of following along the steps.

But wouldn’t it be nice if you could just click one button and have the whole process be done for you? Of course there are solutions out there that do this. But as with any product you need to weigh the benefits against the drawbacks.

Some web hosting providers, like 1&1, provide a one-click installation of WordPress. When I last tried this about 6 months ago it was as simple as can be: just click the icon and a few minutes later you have a WordPress blog. The problem with this particular setup was that it ran as a shared installation and I did not have access to the WordPress directory. This made it impossible to install any new themes or plugins, thus defeating the main benefits of WordPress, in my opinion. Honestly I did not spend a lot of time to figure out if there was a way to install themes and plugins with the 1&1 setup. (If you know how please post a comment on this blog.) It was just quicker to install WordPress manually.

Many web hosting providers that offer cPanel also include Fantastico De Luxe. This is a tool that has installation scripts for many products, including WordPress. Since it’s integrated with cPanel, it’s very easy to use. One important item to be aware of regarding installation tools like Fantastico is which version number is being installed. Open source projects typically release new versions often. In many cases it doesn’t matter if you’re not running the very latest release. But when there’s a security issue involved you really want to be able to quickly upgrade to the latest version without having to wait for the installation tool to be upgraded and then for your web hosting provider to upgrade the installation tool.

Wikipedia has a good article on Fantastico.

Why use BlueHost for your WordPress blog?

6 March, 2007 (14:45) | WordPress | By: Nick Dalton

There are thousands of web hosting providers and dozens of web sites dedicated to evaluating and recommending reliable web hosts. Without diminishing the value of these sites, here are the simple reasons why I selected BlueHost as the web host in the WordPress Installation Tutorial:

  • BlueHost is listed on the WordPress.org Web Hosting page. The WordPress community is a tough crowd to please when it comes to commercial services. Their integrity, and thus their recommendation, carries a lot of weight with me.
  • Their versions of PHP and MySQL are recent enough to run the latest version of WordPress, and likely the next version as well.
  • cPanel is included which simplifies setup.
  • The price of $6.95 is competitive for the features included (host up to 6 domains, 200 GB storage and 2,000 GB transfer). If you pay for 12 months in advance one free domain name is included.
  • You get $50 worth of free Yahoo credits and $25 free Google credits. This almost offsets the cost for 12 months of hosting. (Be careful with your Google and Yahoo ad campaigns though; you can use up $75 in a hurry. Better get help from an expert before you get into too deep water.)

The Installation Tutorial shows how to setup your own domain and web hosting using BlueHost as an example. If you already have a hosting provider you can of course skip this video and begin with the next step: Download and unpack WordPress.