Anniversary Wrap-up and Inside Look
I'd just like to thank everyone who took part in the Atomic Bird five year anniversary last week, including customers (both free and paid), blog readers, and those who contacted me directly by email.
Just a little snapshot to hint at how things went. This is how Mint shows recent traffic to this web site:
Wow!
I thought people might be interested in knowing how the whole one-out-of-five-free thing worked.
Step 1: Coupons
Free orders were managed with single-use coupon codes which would give a 100% discount on software in the order (CD-ROMs were not free). My orders are processed by eSellerate, and they have a system where it's possible to generate a long list of single-use coupon codes with the same effect and named with the same prefix. For example, "FIVEYEARS-0JL8JCVC" was one of the coupon codes. All of them started with "FIVEYEARS-" and the rest was random.
These coupon codes were set to be valid only for the week of the anniversary (and that one's been used anyway).
Step 2: Distributing Coupons
Giving out free orders to one out of five customers was handled by some custom PHP code on my web server, which would consult my order database to decide when it was time for a free order. I set this up as a web-store redirect script, and modified all of the "buy" links on the web site to point to it. The basic pseudo-code was:
- See how many orders had been received since the start date
- See how many free orders had been received in that time
- If the number of free orders was less than 20% of the total, get a coupon code and give the person a free order.
- Redirect the person to my web store, regardless of what happened in the previous step.
Because there's a delay from giving out a free order until it appears in the sales database, this meant that it was likely I'd end up giving out two or more free orders in a row. After one coupon code was given out, someone else might come along before the first person had a chance to use it, and there would be no new entries in the sales database. Free order (again)! Over the course of the week it averaged out, even though at any given moment the proportion of free orders might have been slightly higher or lower than 20%.
I could have just chosen random numbers from 0 to 1 and given free orders if the result was 0.2 or less, but I didn't want to make it too easy to game the system.
I also had to make sure not to give out the same coupon code more than once. Each code could only be used once, and I didn't want someone who should get their software free suddenly find themselves with a used, useless coupon code. For this I loaded all of the codes into a database. It was a pretty trivial database, having only one table with two fields (coupon code and a flag to indicate if it had been used). But it gave me a convenient way to ensure single-file access to the list of coupon codes. With MySQL I'd lock the table for writing, get a code, mark the code as used, and then unlock. If the table couldn't be immediately locked, MySQL would wait until it could.
If traffic through the redirect script got too high when it was free-order time, people might have to wait a moment while the code was retrieved, but I'd know that once they got the coupon that it'd work for them.
Step 3: Making it Make Sense
Despite my best efforts, not everyone knew about the anniversary and the promotion. I needed to make sure that if someone suddenly found themselves getting a free order, they'd know what was going on (they might not mind, but might also be confused). I set up an alternate version of my web store. It was actually the same store, but with a different appearance. This version added a message at the top explaining what was happening in bright, friendly letters that were hard to miss.
Putting it in action
I'm not a PHP guru by any means, but it all worked and that's what counts. I did have a hiccup in the system where it would sometimes fail to apply the coupon (resulting in an unexpectedly non-free order). But Daniel Jalkut and Paul Kim helped me discover them and get them fixed. Remember what I said a few days ago about getting to know other developers? This is where it really helps. It was more than a little disconcerting to have this kind of problem but having friends find it fast definitely helps.
Another error resulted in the first eight orders being free. Duh. But I got that fixed on the morning of the first day, and it still averaged out to 20% of orders being free over the week.
The End
Thanks again to everyone. Now to start planning the 10-year anniversary bash...
Submitted by Tom Harrington on Mon, 10/22/2007 - 15:24.






