For our online shop, we are giving out coupon codes (also called "promo code" or "voucher code").
Currently, these codes look like an insane developer has designed the format:
FCF4A803-18F0-46BE-A14D-6F26101C9E01
In fact that insane developer was me. I've used a GUID.
Now I'm seeking for a (at least slightly) more usable format.
I can imagine of something like YouTube video URLs:
BROWqjuTM0g
Or just the current timestamp in ticks:
635507907277936690
Or the current UNIX epoch time:
1415200070
Or maybe some prefix to identify our product? Like e.g.:
PROD1415200070
My question:
How would you "design" the format/syntax of a coupon code?
Update 1:
I forgot to mention: We are giving out multiple different coupons. So something like "BUYIT" or other meaningful strings would not fit. I guess we need some random part.
Answer
If you need a lot of different unique codes it matters whether the user will have to manually type it in, and it will have to be generated algorithmicly.
Typed in Manually
For something they'll have to type in, and still sufficiently random, I've done this before by generating a string like GHJ5-JKG4
.
Start by picking a random number between 0 and 31. (A-Z, 0-9, and take away 1, 0, I, O). Append that character to a string. so, g
then h
then j
etc. You'll have ghj5jkg4
using the above example.
Check that string for inappropriate language. You don't want to randomly generate something like 1fuck3r5. As suggested in the comments, removing just vowels may be sufficent, especially if you don't use numbers.
Convert it to uppercase GHJ5JKG4
, then store it in a DB. When displaying it to the user split the string in half separated by a hyphen GHJ5-JKG4
as people have a hard time remembering more than 4 characters.
When you check to see if it's valid, just strip non alphanumeric characters and lookup GHJ5JKG4
in your DB.
Unique code in email
You can get away with a longer string. Append the first ten characters of the MD5 hash of the current unix timestamp to a keyword for example.
FREE8CD89BAB45
Non Unique Code
Whatever looks nice!
FREESHIPPING from @RomC being a great example.
No comments:
Post a Comment