How to generate a unique promo code?
After filling out the sign-up form on the website, it is often necessary to add a one-time promotional code into the content of the auto-email. If your CMS does not have such a module, use the instructions below.
An example automation is described in the article Grow Your Mailing List Campaign.
Important! All settings must be done by a professional, as there is a possibility that your website will stop working due to incorrect changes.
Logic of the operation
There is a code on the website that generates a new promo code every time this script is accessed. A code is added into the submit button of the web form, which calls this script and gets a new promo code from the website. Then it sends it to InSend and the data is replaced in the email.
Configuration of the generation of a unique promo code
If your CMS does not have a built-in module for generating promo codes, there are several options:
- Implement the module yourself
- Find a third-party module and implement a script for this module
How to implement a promo code request in InSend
- Create 2 custom events in InSend with the keys: request_promo_code and response_promo_code
- Create 1 property field in InSend to store the promo code with the key code
- Create a webform in InSend and add an event code to the widget button to request a promo code:
insend('event', 'custom', {key: 'request_promo_code'});
- InSend API you need to create a webhook with events/custom theme that will call the script on your website.
- Create a script on your website that accepts a webhook and validate it (check that it comes from InSend's IP address and not from the DDoS servers' address). Check if the webhook is triggered by the "request_promo_code" event (sent by the widget through the user). If all conditions are met, you need to generate a new promo code, get the UID of the user from the webhook and send another user event with the "response_promo_code" key to InSend on behalf of this user. Replace the promo code in the contact details.
- In InSend you need to create an auto email that will be sent on the "response_promo_code" event. Add the substitution %{code} in the content of the letter. So that the promo code is automatically inserted into the email.
Links to libraries
To work with the Convead API, you can use the php or ruby libraries.
To work with Convead EVENT, you can use the php or ruby libraries.
See the readme file for examples of how to use the code. If your platform uses a different language and these libraries are not suitable for you, you can write your own code. Events are sent via a regular post request (the structure can be seen in the code of these libraries). Api requests are sent via the RESTfull protocol.