PSA: Don’t Generate Offensive Promo Codes

OK folks, I’m now on my 3rd client having problems with certain four letter words coming up in their automatically generated promo codes. It’s easy to get around this problem in a very simple way: Don’t use vowels in your promo codes if you’re using letters. No need for special filtering software or huge lists of banned words. You can always add complexity later, but that simple rule will help you more than the rest.

If you want to get more careful, you could alternate letters and numbers, or use some other strategy. To be kind to your users, be aware that some numbers and letters look the same to people and they will enter your codes wrong (or worse, enter in someone else’s code by mistake).

To help you, here’s a list of the numbers and letters I suggest people use because they won’t get them confused with each other and hopefully your system won’t create any bad words (if they do, let me know). If you’re worried about the number of combinations you can make, just add more characters to the length of your code or allow yourself the option to generate your own special codes.

letters = [‘B’, ‘C’, ‘D’, ‘F’, ‘H’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’]
numbers = [2, 3, 4, 7, 9]

You could then take this and make a simple ruby method that does something like this:

letters = ['B', 'C', 'D', 'F', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z']
numbers = [2, 3, 4, 7, 9]
promo_set = letters | numbers # combine arrays
promo_code = promo_set.sort_by{rand}[0..14].to_s # randomize array and take the first 15 elements and make them a string
=> "CS4FZLHVMPK3QJN"

One Reply to “PSA: Don’t Generate Offensive Promo Codes”

  1. B4D4SS.

    We did alternating numbers and letters on a previous project but didn’t catch the case where a one or zero stands in for the second letter of a kewl-ly misspelled four-letter word.

Leave a Reply

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