How to add metadata (custom attributes) to Voucherify objects?
In this section:
What is metadata? 🤔
Metadata enables you to add custom data to Voucherify, which you can later use for building validation rules and reporting/ tracking. Every object type like:
Add metadata with Metadata Schema ➕
Metadata Schema allows you to take care of the integrity of your metadata. This is achieved by enabling administrators to set a type of each metadata field and to define if it’s optional or not. The schema works for every object type:
⚠️Only Administrator can access and modify the validation scheme
Create metadata - schema validation
Let's see an example of the schema validator. We're going to add a custom field `affiliate_ID` to all campaign and redemption objects in the project. This way campaigns can have optional metadata of affiliate_ID and redemptions invoked by them will also have proper metadata assigned. This way you can easily track which affiliates bring in the most redemptions.
To start with, go to the project settings and find Metadata - Schema section ➡️
First, choose Voucherify objects to assign metadata. You can define properties for campaigns, vouchers, publications, redemptions, products, SKUs, customers, and orders.
In order to start, click Add new definition.
- In the next step, define a property name and type. Let's use an affiliate_ID as a property assigned to the project's campaigns and redemptions.
- You can choose between several different property types:
- Here, you can add some optional length constraints or even set a condition that the metadata property has to be an exact match to the value (or many custom values).
💡 You can mark the checkbox to set each property as optional. Otherwise, it'll be treated as required.
When all campaigns' restrictions are in place, SAVE your schema ✅
Now, let's define all redemptions invoked amongst this project by the same affiliate_ID. Just select Redemption objects and repeat the previous step of the tutorial.
Run a campaign 🏗️
As a result, while creating a new campaign (by a user assigned to this project) in the 4th step of a campaign creator, there will be a default metadata field with an affiliate_ID. To create a campaign, the user has to put the required property value, set by a project administrator in the validation schema.
Otherwise, the user won't be able to save and generate campaign 😥
Invoke redemption 🧝
Additionally, by adding the same restriction to a redemption invoked in the context of this project, a field with the particular affiliate_ID is required for a redemption request to be valid.
Target specific segments 🧑🧔🧓
You can create metadata validation schema for "customer" objects and use it for a later segmentation. By way of example, you can add a membership field to the schema and collect information about membership levels to offer different incentives for different members.
After adding this field, you'll be able to filter out your clients by using a membership field. Later on, you can easily create a segment with customers who meet the criteria defined by schema properties.
Watch this short video to see the metadata in action 📹
You can also follow this guide to learn more about customer segments 📔