Customer tracking

Voucherify can help you track anonymous customers. Once you integrate into your web app using JS SDK and call validate method, Voucherify will return a tracking ID and the script will store it in a cookie. Every next validate call will be using the same tracking ID.


Customer tracking workflow in a nutshell:


  • A customer visits your website.
  • She validates her voucher code. That triggers JS to send a validate request to Voucherify. As a result, it returns a tracking_id.
  • Once she finishes the checkout process, your website passes the tracking_id to your backend during a redemption.
  • A customer object object is created and within the redemption response you get a customer_id.
  • You can use the customer_id to fetch or modify the customer details.

A customer is created (upserted) automatically with every redeem call. Alternatively, you can create a new profile with create customer operation. Take a look at the customer object to understand the entity's structure.

How to set identity

Voucherify allows you to bind data to a specific user by creating a profile.

In this example, we're going to create a new profile with the given ID of your customer. Based on this value, Voucherify will generate tracking customer identifier (e.g. track_rAqzJcOeccLyJFGU8OTSHZgjwTe2e7nz) which can be used to track behavior of any user using your platform. Even if you don't pass an ID to Voucherify, our API will generate hashed identifier related to your customer profile.


Voucherify.setIdentity("[email protected]");

Your format of ID e.g. phone number or email address.

After first interaction with Voucherify API, you will get back hashed value of customer tracking token. In the vast majority of cases the first request will be a voucher validation. Below you find an example of response from Voucherify.validate("VOUCHER-CODE") method:

  "valid": true,
  "discount": {
    "type": "PERCENT",
    "percent_off": 15.0,
  "tracking_id": "track_rAqzJcOeccLyJFGU8OTSHZgjwTe2e7nz"

You may keep the hashed identifier and use it in future to fetch customer details, e.g. redeemed vouchers, validations or a profile details.


Secure redemption request

For security reasons, we link users who validate vouchers with users who consume them. Therefore, if you want to have even more secure integration with Voucherify API, please use customer tracking identifier as the token in the redemption request.


    voucher: "Testing7fjWdr",
    customer: {
      source_id: "alice.morgan", // or tracking_id returned from validation method
      name: "Alice Morgan",
      email: "[email protected]",
      description: "PREMIUM customer",
      metadata: {
        country: "us",
        type: "PREMIUM",
        favourite_brands: ["Armani", "L’Autre Chose", "Vicini"]
  .then(function (result) {
  .catch(function (error) {
    console.error("Error: %s", error);


Customer identifier

Source id of the customer in this example may be either already hashed version of tracking id you received in a response from a validation request or a custom ID you predefined. Nevertheless we recommend using identifiers delivered by Voucherify API.