2

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.

  • 2
    What are the functionality requirements of the coupons? Do you generate a unique coupon for individual users? – user31143 Nov 5 '14 at 16:47
  • @dan1111 yes, unique coupons. – Uwe Keim Nov 5 '14 at 17:38
3

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.

  • 2
    In this article, the author recommends to simple remove all vowels (a, e, i, o, u) to get rid of possible offensive words. – Uwe Keim Nov 6 '14 at 6:43
  • 1
    Heh, true enough. If you don't use numbers either that definitely works. – evandentremont Nov 6 '14 at 6:49
2

Let’s say you need a million codes tops. We’ll use a friendly scheme that has a milliard/billion possible combinations, but could be scaled up easily, so not every possible combination yielded a valid coupon code.

Get a list of 1000 short and frequent non-vulgar words, preferably from the same category, e.g. just nouns. Randomize their order. Assign to each a unique zero-padded three-digit number from 0 through 999 (could be the line number in a text file decreased by one).

Define a pattern to make only one in thousand numbers valid, e.g. every fourth digit is the check digit for the preceding three digits. Regroup by digit triplets. Select the words from your secret list that are identified by these numbers.

123_456_789_ – 1+2+3=6; 4+5+6=15, 1+5=6; 7+8+9=24, 2+4=6
123645667896
123 645 667 896
rabbit tennis engine water

These words are easier remembered and typed (and spelling-corrected) than random numbers.

You can even internationalize this with word lists for other languages that arbitrarily coded the same numbers.

Garten Waage Müll Norden

Accept words in any capitalization. Throw away digits and punctuation.

This is just from the top of my head. Ask mathematicians whether a single check digit would suffice, whether you should use smaller or larger lists or if the word number should depend on the word position (i.e. 000000000 results in four different words). My only point is, change random letter and digit sequences into simple words. A very short list of words could be populated with ones meaningful to the business of the site.

1

Without any additional rules that would define what values can be used for a coupon code (or any restrictions), I recommend something that would be (1) easy to remember and (2) something that sort of describes the kind of discount that can be obtained.

Examples:

SAVE25%OFF
FREESHIPPING
WIDGET123 (Product name like you suggested - at least it implies that the coupon code is for that specific product only).

  • Thank you! I've updated my question. Actually I need lots of different codes, so probably I need some random stuff in the code?!? – Uwe Keim Nov 5 '14 at 15:48
  • 1
    Why don't you just tie the code to the email account so they are unique? Takes the burden off the user. – Mark Sloan Nov 8 '14 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.