This article explains a way to track voucher codes assigned to each customer profile when using the Jinja function assign_available() by storing the voucher code directly in the campaign event created in the customer profile.
By default, every call to assign_available() picks an unassigned voucher from the selected voucher pool, but the specific code isn't stored on the customer profile out of the box.
The documentation (Vouchers documentation – Reuse vouchers) already describes several options for tracking and reusing vouchers, such as storing the assigned code in a custom customer attribute or via custom events and aggregates.
In this alternative, you don't need extra attributes or events. You only add Custom Campaign Tracking (CCT) parameters.
How to set up voucher tracking
In the campaign node's Settings, you can set the Custom Campaign Tracking (CCT) parameter.
For the Attribute name, write the value under which you want to store the voucher code. You can name it, for example, "voucher_assigned". In the campaign event, the attribute will appear with the CCT prefix "c_", for example, "c_voucher_assigned" in our case.
As the Attribute value, use the same function that assigns the voucher, where voucher_pool is the name of your voucher pool catalog. It makes sure the voucher code shown in the email matches the code stored in the campaign event.
{{ vouchers['voucher_pool'].assign_available() }}
Summary
By combining Jinja's assign_available() function with Custom campaign tracking on the email node:
You keep your existing voucher logic for displaying codes in emails.
You add a simple way to track which code was assigned to each customer.
The code stored in the CCT parameter matches exactly what the customer sees in the email, making troubleshooting and reporting much easier.
This approach removes the need for extra custom events or complex aggregations in many common voucher use cases, while remaining fully transparent and easy to maintain for your team.