Reuse voucher codes

The Jinja code {{vouchers['voucherpool_name'].assign_available()}} randomly selects a code from the pool. By default, Bloomreach doesn't track which code was assigned to which customer, so you can't automatically give the same customer the same code in future campaigns.

To reuse a code, store it on the customer's profile as a customer attribute or a custom event attribute. Then display it with Jinja whenever you need it.

Before you start

Import your voucher codes into a pool and set up voucher tracking.

Choose a method

You can reuse the same voucher code in 2 ways:

  • Custom customer attribute: Add the code as a customer attribute and retrieve it using {{ customer.attribute_name }}. These codes don't need to be unique.
  • Custom event attribute: Assign the voucher as a custom event attribute and retrieve it through an aggregate. Use this approach if you want to track which voucher a customer received and when.

Use custom customer attributes

This is the simpler of the 2 approaches.

  1. Go to Data manager and create a new customer attribute. Give it a name you can identify as a voucher—for example, voucher, temp_voucher, or voucher_assigned.
Data manager showing a new custom customer attribute being created and named for voucher use

You can populate this attribute in 2 ways:

  • Set attribute node in scenarios: Add a Set attribute node to your scenario and configure it to assign the voucher code to the customer attribute.

    Scenario flow showing the Set attribute node configured to assign a voucher code to a customer attribute
  • Customer attributes import: Import voucher codes as customer attributes using the Customers rather than the Vouchers import.

Once the attribute is populated, it looks like this:

Customer attribute screen showing a custom voucher attribute populated with an assigned voucher code named testvoucher

Use {{ customer.voucher }} to display the voucher code wherever you need it in your campaign.

Email editor showing Jinja code used to display a custom customer voucher attribute in campaign content
📘

Note

This approach works best for smaller customer bases. You'll need to update the attribute each time you assign new vouchers.

Reuse vouchers using a custom event attribute

  1. Create a new event and name it. For example, voucher or voucher_assigned.

  2. Add attributes to the event, such as type, voucher_code, and status. These attributes help you identify specific vouchers in analyses and dashboards.

  3. In your scenario, add an Add event node and place it before the email node.

    Scenario flow showing the Add event node placed before the email node to track voucher assignment
  4. Create an aggregate that looks for the voucher_code attribute at the customer's most recent voucher event. Filter by type and status to ensure the aggregate pulls only the latest code for the relevant campaign.

    Aggregate configuration pulling the voucher_code attribute from the customer's most recent voucher event, filtered by type and status
  5. Use the Jinja expression for this aggregate to call the voucher_code attribute whenever you need to display the voucher code in a campaign.

Campaign editor showing the Jinja expression for the voucher aggregate used to display the voucher code

Jinja expression for the voucher aggregate used to display the voucher_code in a campaign.


Did this page help you?

© Bloomreach, Inc. All rights reserved.