โ—พGenerating promo codes

This use case demonstrates how to generate random promo codes, send them to users, and store them for future verification.

Creating a label tag

Create a new label tag in the Tools \ Label tags, select the tag value type as "JavaScript Function", call it "promo_code" (or any other name), and place the following code that generates a random code every time the label tag is used.

You can adjust it to limit the set of characters used in the promo code and its length.

Creating a popup with the code

Create a popup resource based on the template "Promo Code with Label Tag"

You will need to pay attention to two main parameters:

  • The name of the label tag that you have created in the previous step

  • A special code in the section "When shown", you can leave it as "CODE_IS_SHOWN", this code will be used in the next step.

Build a campaign

Create a Realtime campaign (Journey) that will show the popup.

Test it; you will see that the pop-up sent to the client contains randomly generated code.

Call your API to save the promo code

Extend the campaign with "Wait for event" activity, select "Client action" as the event, and "CODE_IS_SHOWN" as the action name.

Note: If you don't see the client action "CODE_IS_SHOWN", make sure you have tested the previous step, and the popup was shown to you. You can also go to the Tools \ Properties, find the property "Core: client action" and use the "+" sign to register this action manually.

Connect "Wait for event" activity to the Popup on "Impression".

Create a "WebHook" activity that makes a POST request to your API and passes the generated promo code. For example, you can use a simple JSON structure like the following:

Connect the "WebHook" activity to the "Wait for event" using the "When happened" connector.

The final flow

How the flow is working:

  1. When the campaign is triggered, Smartico will start preparing the popup to send to the user

  2. As part of the preparation, it will generate a promo code and place it into the popup.

  3. When the popup is delivered, Smartico will progress the flow by "Impression" connection to the "Wait for event"

  4. Right at this moment, the Popup will trigger "Core: Client action" event with action code "CODE_IS_SHOWN" and the actual promo code that will be passed in "event.code".

  5. The flow will proceed to the WebHook and call your API with the code value populated from the {{event.code}}.

Next steps and ideas

  • Save the submitted promo code via the API and verify it on the next deposit.

  • Play with the popup template to adjust UI, text, and images

  • Review the JavaScript code that generates promo code and adapt it to your needs (length & character set)

  • Use different communication channels to deliver promo code - emails, pushes, telegram, SMS etc.

  • Make a copy of "Promo Code with Label Tag" popup template and adjust it to match your style and layout needs.

Last updated

Was this helpful?