How can I use the same voucher code multiple times?

The conventional way of assigning vouchers using the Engagement platform is using the Jinja code {{vouchers['voucherpool_name'].assign_available()}} This code will assign a voucher code from the pool at random. The platform will not track which code was assigned to which user out of the box, which restricts reusing the same code for the same user again in other/subsequent campaigns.

There are two common approaches how to reuse the same voucher code later:

  1. adding it as a custom customer attribute and using {{ customer.attribute_name }} Jinja to call the voucher (there is no need for these codes to be unique)
  2. assign the voucher as a Custom event's attribute so it can be called through aggregate and used as many times as needed.

When to use what? The approach with Custom events gives an overview of what voucher was assigned to a customer and when. All that information, along with additional data, can be stored in Custom events.

Guide on how to use custom customer attributes to reuse voucher codes.

This one is the simpler solution of the two, and all you have to do is create a new attribute from your Data Manager and give it a name that you can later use to identify it as a Voucher (voucher, temp_voucher, voucher_assigned etc.).

This custom customer attribute can be populated in two different ways.

The first way is by the 'add attribute' node in Scenarios.

Instructions on how to assign vouchers using the ‘set attribute’ node will be provided later in this guide.

The second way you can assign voucher codes as attributes is to import them via the import Customers attributes as opposed to Vouchers import which is typically used for uploading vouchers.

Once the vouchers are updated, the attribute will look something like this.

From here it is as simple as using basic Jinja code {{ customer.voucher }} to display the Voucher code every time you need to display this particular code.

This solution will be best suited when you have a smaller number of customers you need to assign vouchers to. Because you will need to update this attribute every time you need to assign new vouchers.

Guide on how to use custom customer events to reuse voucher codes.

Create a new event named voucher/voucher_assigned or something of your choice and give it attributes that you might want to later use to narrow down which campaign/flow the voucher code belongs to.

The key to the next step is the ‘Add Event’ feature you see in Scenarios. You need to place the ‘Add Event’ node before the email node so the voucher event is added.

Inside the ‘Add event’ node, you need to use Jinja to assign vouchers.

What the above node will do is add a ‘voucher’ event to every customer that passes through the node and it will have a voucher code in the ‘voucher_code’ attribute.

Then create an aggregate that will look for the last voucher event’s voucher code attribute for each customer. (we will also further narrow it down by attribute ‘type’ and ‘status’ to make sure the aggregate pulls only the latest voucher_code for the relevant campaign).

Once the aggregate is created, we will use the Jinja for this particular aggregate to call the voucher_code attribute on every occasion where you want to display the Voucher code.

You can refer to our documentation on vouchers for additional information on the feature.

👍

Did this article help you?

Please provide your feedback. We would like to know if our help center is effective in solving your queries. You can also leave comments and suggestions on how we can make our help articles better. You can also suggest topics you’d like us to cover.