Archives

April 2004 (7)
March 2004 (12)
February 2004 (12)
January 2004 (22)
December 2003 (19)
November 2003 (16)
October 2003 (26)
September 2003 (18)
August 2003 (38)
July 2003 (80)
June 2003 (13)
May 2003 (24)
April 2003 (76)
March 2003 (75)
February 2003 (51)
January 2003 (73)

Category

Family (5)
FYI (18)
Games (2)
Geek (88)
Geographic (3)
Hacks (13)
Home (15)
Humor (54)
Ideas (20)
Ideaspace (15)
Local (15)
Metadata (10)
Microsoft (2)
MovableType (5)
Nitwits (66)
PKI (2)
Politics (22)
Quotes (3)
RDF (15)
RSS (4)
Security (3)
Semantic Web (13)
Site Info (13)
Social Networks (1)
Spam (9)
Sysadmin (1)
Tips (2)
Tivo (2)
TMFTOTHD (1)
To Do (1)
Unlisted (1)
Web (3)
Windows (1)

Local

« MetroBlogs »
DC metroblogs
beltway bloggers

Links


Assorted bits

Blogroll Me!
GeoURL
Listed on BlogShares




April 08, 2003

Capturing links

Let's say you want to know if people are using the links on your page. If you use plain HREF links you can't easily track them. What you have to do is capture the links.

Doing this, without a lot of manual editing, is often a pain. There's one way to do it without a lot of data entry hassles. Use an MT plugin to rewrite the links using a macro. Here's how...

This is a multi-step process. Proceed at your own risk. You'll have to know a bit about creating and editing MovableType templates. You'll also have to know how to install and manage various sorts of add-ons. This is not a step-by-step tutorial. If you hose your MT site don't come cryin' to me.

First get a click-trough tracking tool. There are several available, here's few for PHP. Install it and note what URL it uses to handle the redirects.

Then go get Brad Choate's MTMacro plugin and install it. Once it's installed, create a new index template and copy your current home page index template into it. This to give you a good starting point. Be sure to instruct the template to save it into some temporary filename. Once you're sure this works you'll want to rearrange this into the proper place.

Now I edited my template such that it contains this text at the start:

<MTMacroDefine name="prefix" string='href="http://'>
href=http://example.com/cgi-bin/click/click.php?http://
</MTMacroDefine>

This is a macro definition that tells the rebuilding process to look for the 'http://' prefix and to replace it with your customer click-through URL prefix.

Now find the places you'd like to have URLs changed to use the macro. I put a wrapper around <$MTEntryBody$> like so:

<MTMacroApply macro="prefix">
<$MTEntryBody process_tags="1"$>
</MTMacroApply>

The use of the macro here tells MT to dig into the entry body, find anything starting with href="http:// and replace it with my link tracker. It's important to limit how much the macro searches. By wrapping only the EntryBody section it doesn't disturb the rest of my site's links.

Here's my regular home page and here's one with click tracking turned on. The user experience for them is exactly the same. They click a link and are taken to a web page. What's happening with tracked links is a database is updated noting the use of the link. I can use other tools to check the database and see what links are being used.

Technically, yes, you can glean this same information by reading the webserver log files. However, if you want to perhaps do something different based on how links are used this is an opptune way to do it.

Tracked links like this aren't good for bookmarks. The URLs get long and if your link tracker is broken users might get confused. Once they get to the distant site everything's fine. It's only a problem if they make a bookmark based on the link directly from your site.

Adding link tracking is pretty easy. Whether or not it's a good idea is up to you.

Hacks
Perma  | Comments (0) | TrackBack (0) | 12:59 PM  | xml
Comments
Post a comment






* if you do not leave a valid e-mail or URL your comment may be deleted *







Navigation

Recent Entries

America and Europe: Vive la différence?
Server changes afoot
Diet behavior mod
Googling for sensitive info
Outlook 2003 and IMAP, a marriage made in Hell
Bike to Work Day, May 7th
Speakeasy rocks
Zippo USB?
When geographic data is nowhere 'near' correct
Local campaign contributions

User comments
Trackbacks

Contact

send me an e-mail E-mail
chat with me using MS messenger MSN Messenger
chat with me via AIM America Online
chat with me on ICQ ICQ
chat with me on Yahoo! Yahoo
Add my vCard to your electronic addressbook vCard
Friend of a Friend FoaF

Syndication

XML  RDF  CDF

Comments

XFML

Extra Stuff

foaf
vCard
pgp info
Linked In
Powered by
Movable Type 2.64