Home Engineering Tracking Pageviews On Craigslist
Engineering - Web Dev - December 1, 2010

Tracking Pageviews On Craigslist

I’ve recently been forced to put my 2001 Toyota MR2 Spyder up for sale. I decided that the easiest place to put it up would be to put it up on Craigslist. Obviously the cost/benefit analysis of posting on craigslist is definitely worth it. I could have my car ad viewed by people for free.

But, the question is: how many people would actually click and see my ad?

Craigslist Home Page

When you put up a Craigslist ad, I don’t know of any way to track the number of times that ad has been visited through any sort of Craigslist interface. I’m sure there’s probably third-party tools that do similar stuff, and you could probably install counters or whatever, but I decided to roll my own.

Craigslist allows you to put in limited HTML. There’s even a handy Craigslist HTML allowed tags over at: http://www.craigslist.org/about/help/html_in_craigslist_postings/

Obviously you’re not allowed to run any sort of server side code; they strip out javascript, but they do allow a few HTML tags and they allow inline CSS. (Which they don’t mention on that howto). So I decided to steal an old trick from email marketing, and create a 1x1pixel image link to a php script on my server.
<img style=”height: 1px; width: 1px;” src=”http://www.myserver.com/script.php” alt=”” />

Whenever someone visits this page, they’ll trigger script.php to run. You can use $_GET variables if you want to track different posts with one script, you can store it in a database, you can have it email alert you whenever anyone views the page, the sky’s the limit. Personally I was just hacking it together quickly, so I had it send email alerts to a throwaway email account. It’s definitely not the most elegant solution, but if you want to see what I did, it’s here:

mail(“xxx@yyyy.com”,”MR2 PAGEVIEW”, “MR2 PAGEVIEW”);

And the post itself (while it’s still up) is here: http://losangeles.craigslist.org/lac/cto/2088021757.html

One Reply to “Tracking Pageviews On Craigslist”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.