Hello,
I want to send unique (promo) codes to customers when they register for an event of product mailing.
These codes should be generated automatically when people fill in the form and send to them with their conformation.
Does anyone has an idea what the best way is to do this?
Hi,
Depends on the process for generating, and later verifying, the codes.
If they need to be taken from a pre-generated list, then you'll need a webhook to "pop" the next unused one off a stack stored in a file.
If it's a more casual situation where you're not worried about the code being generated securely/verifiably, you can generate an alphanumeric code in JavaScript (in the browser) and add that to the form as a hidden field. Only allow that field, call it PromoCodeEvent1982, to be set one time by blocking updates in Admin » Field Management. Let's say a sample PromoCodeEvent1982 value might be "BEBZ".
Then you can use that to assemble a final unique code. Concatenate
{{lead.Marketo Unique Code}} +
a static value that represents this particular event, in this case "E1982" +
{lead.PromoCodeEvent1982}}
That'll give a final code like
XYZPDQ-E1982-BEBZ
It's obviously forgeable because they could hack the "BEBZ" part, but they wouldn't know the rest in advance.
Again, though, depends on what you actually need to do w/these codes. More typically I see codes with real monetary value, and they need to be assigned from a list of valid codes.