Fast-track your loyalty program with Voucherify and Twilio Segment

Whether you are starting a new project or moving from legacy systems, this recipe will help you build a composable foundation for your retention program. This tutorial guides you through combining Segment and Voucherify to enhance your loyalty program by automating member sign-ups, tracking loyalty-related events, and deepening loyalty profiles. 

Made by Voucherify
Segment Made by Segment

What do you need?

  • Voucherify
  • Twilio Segment

Easily personalize customer experiences with first-party data

With a huge integration catalog and plenty of no-code features, Segment provides easy-to-maintain capability to your teams with minimal engineering effort. Great data doesn't have to be hard work!

On this page

In this recipe, you’ll learn how to implement a composable loyalty program using the Voucherify loyalty engine and Segment’s event streaming and profile explorers. We will use Segment’s features such as Identify Calls, Insert Actions, and Computed Traits to build advanced loyalty workflows such as automating member sign-ups, integrating order tracking, enriching loyalty profiles, or triggering various loyalty actions. 

This recipe contains links to an open-source environment that can be used as inspiration and for further testing.

Workflow Diagram for Customer Loyalty and POS Integration

Automate member sign-ups with Identify and Track calls

When a customer enrolls in a loyalty program, Segment can trigger either an Identify or Track call, which is then passed to the Voucherify destination to update or create a customer profile, assign loyalty cards, and initiate loyalty actions like awarding welcome points.

  • Identify Call: Ideal for cases where customers sign up by filling out a form, as it captures user information.

  • Track Call: More appropriate when membership enrollment requires a specific action, such as purchasing a membership.

The approach depends on the sign-up process, and in this setup, you'll create separate sources for both the loyalty mobile app and a POS simulator. It is possible to connect as many sources as you need including online stores to cover all possible touchpoints.

Step 1: Create sources

  1. You need an account with Segment and an existing Source for server-side tracking.

  2. Install the appropriate Segment SDK for your server environment (Node.js, Python, Java, etc.). 

  3. Set up the SDK with the write key from your Segment source.

  4. Use the SDK to send various event types (e.g., track, identify, page, screen, etc.).

It is also possible to run a client-side connection by placing Segment tags in the HTML of your website, however, this method is far less secure for production deployments. 

Step 2: Set up Identify calls to recognize members

The Identify call links a member’s behaviour to their identity by sending traits like name, email, or user ID. After installing the Segment tracking script, use analytics.identify() to associate traits, including custom ones like loyalty_status or points_balance. Ensure traits align with the events you plan to track and the downstream tools (e.g., Voucherify, Braze) that will receive the data.

Segment is ideal for centralising and distributing data across multiple systems, especially when real-time tracking of customer behaviour is crucial. Voucherify specialises in managing promotions, loyalty programs, and coupons, making it a good fit for handling loyalty tier data in the context of rewards and discounts.

The choice between using Segment or Voucherify as the source of truth for loyalty depends on data storage (centralised vs. specialised), synchronisation needs (real-time vs. batch), and whether loyalty data is part of broader customer profiles or specific to promotions.

Step 3: Set up Track calls to log member actions

The Track call allows you to log user actions. Each track call records an event along with event properties. After installing the Segment tracking script, you can call analytics.track() to log events. Once track calls are set up, Segment will automatically send event data to any connected destinations (e.g., Voucherify, Braze).

Dashboard displaying source schema activity with a line graph and a table detailing traits and their statuses.

Step 4: Send Member Data to Destinations

After setting up your sources, you can send this data to other tools by configuring Destinations.

  1. Go to the Destinations tab.

  2. Add a destination by selecting Voucherify (Actions).

  3. Choose the data sources you want to push to Voucherify.

  4. Complete the configuration by pasting your Voucherify API keys into the destination settings in Segment.

Once Voucherify and Segment are connected, members and associated events will be available in the Voucherify Dashboard. Based on the loyalty workflow set in Voucherify, new members will automatically join a specified tier or receive welcome rewards. 

Integrate events tracking

Whenever a loyalty activity occurs, the complete event data is sent via Segment to Voucherify for accurate, real-time point calculations, tier changes, and other loyalty workflows. Segment also allows you to send custom events, such as purchases at new locations, letting you build custom loyalty actions and deeper reporting.

Step 1: Set up Track calls to monitor member activity

To track events via Track calls, send an event that captures details of each loyalty activity on your website or app. The configuration for Track calls is established when setting up the sources. In our case, the POS application sends order data to Segment through Track calls.

It is possible to pass custom order properties with the Track call allowing you to build advanced earning rules, such as:

  • Get bonus points for purchasing twice from the same location.

  • Get extra 500 points for visiting a new location.

  • Get a free gift for placing the order via a mobile app.

  • And much more. 

In the accelerator configuration, the POS sends order data, including location information, back to Segment and Voucherify.

 

Retail Management Dashboard Showing Order Summary and Customer Activity

Use Sources > Debugger to analyse what type of events and properties Segment captures.

With Voucherify webhooks, you can easily build loyalty reports to see how many loyalty-related orders came from a specific location or source (via metadata). 

Steps 2: Map tracked events 

With event mapping, you can link tracked events to corresponding actions in your connected destinations. In this case, we'll use manual mapping for greater control over how Segment events translate to Voucherify.

  1. Navigate to the Destination Settings and select Voucherify.

  2. Go to Mappings and click New Mapping.

  3. The Voucherify destination offers pre-built mappings, such as saving Segment events as custom events or using the Identify call to create or update members.

Interface showing data field mapping for POS and Voucherify actions.

In the earn-and-burn loyalty model, members will automatically receive points for orders. All loyalty calculations are performed in Voucherify, alongside automatic tier changes or points expiration. 

Deepen loyalty profiles with computed traits

You can use Segment’s computed traits to enhance member profiles and pass that data into Voucherify, tracking metrics like how often a customer purchased product X or visited a specific location. By combining earning rules in Voucherify with Segment’s computed traits, you can reward members for actions such as:

  • Visiting at least 3 different POS locations.

  • Accumulating a total order amount of X.

  • Purchasing product X a specified number of times.

Data can be aggregated in Segment and sent to Voucherify as metadata via a Track event, enabling advanced loyalty actions and segmentation. Loyalty-specific traits (such as loyalty tier status, points, rewards, etc.) should ideally be stored in Voucherify to be easily consumed by APIs and webhooks across various CX tools and reporting systems.

  1. Use Identify calls to define and update custom traits (e.g., total purchases or location visits).

  2. Use Track calls to log customer actions (like purchases or visits) and update traits.

  3. Aggregate this data within Segment, dynamically updating traits based on customer actions.

  4. Send customer-specific metadata to Voucherify with a Track call.

  5. Utilise this metadata in Voucherify to create personalised segments or earning rules.

Two interface screens showing event tracking and details for unique localization and trait count.

Trigger Loyalty Actions with Insert Functions

You can use Segment's insert functions to automatically trigger loyalty actions when specific conditions are met. For instance, when an event in Segment matches your criteria, it triggers an API call to publish a unique coupon code from Voucherify.

Note that you can use audiences or computed traits if you are looking for a no-code method. In this example, you will see how to use functions to implement advanced computations on the streaming data that you send to Voucherify.

To create an insert function from Segment’s catalog:

  1. Go to Connections > Catalog > Functions and click New Function.

  2. Choose Insert and click Next: Build Function.

  3. Write and Test Code: Write your function code, manually enter a sample event, and click Run to test. In our example, Voucherify uses the Create Publication endpoint. 

  4. Configure Function: Click Next: Configure & Create to add a name, description, and logo for your function.

  5. Create Function: Click Create Function to finalize. The insert function will appear in the Functions tab.

  6. Select your insert function, click Connect a destination, choose the desired destination, and click Connect to destination to enable data flow to downstream destinations.

JavaScript code for reward events is displayed in a code editor within a web application interface

Enrich loyalty analytics 

Voucherify can serve as a data source to track loyalty data like reward redemptions. As an Event Cloud source, it sends user events to Segment, which can be loaded into Segment warehouses or streamed to destinations.


Visit the docs to see how to connect Voucherify as a data source.

Screenshot of the debugger tab showing successful operations and raw JSON responses for Voucherify API.

Here are possible loyalty reports you can build by combining Segment & Voucherify loyalty data:

  • Track the number of successful and failed voucher or reward redemptions.

  • Analyze events tied to reward points earned and redeemed by customers. 

  • Measure the success of various marketing campaigns based on voucher publication and usage events. 

  • Analyze events where redemptions failed, allowing businesses to troubleshoot issues or prevent fraud by understanding why customers couldn’t redeem their rewards.

To better visualize loyalty data points, you can connect Tableau or other BI tools as a destination to build visual dashboards with critical loyalty data aggregated from Voucherify and Segment. 

Wrapping up

Here’s what we’ve done in this recipe:

  1. Automated member sign-ups: We implemented a process for capturing customer data at checkout via Identify or Track calls, ensuring instant recognition and engagement.

  2. Integrated event tracking: We set up real-time transmission of events from POS and mobile app into Segment and then to Voucherify, providing valuable insights into customer purchasing behaviors and allowing quick points calculations. 

  3. Deepened loyalty profiles: We leveraged Segment’s computed traits and Voucherify’s metadata to enrich member profiles with custom loyalty data.

  4. Triggered loyalty actions: We used Segment’s insert functions to automatically call Voucherify APIs once event criteria are met, speeding up loyalty processes and minimizing additional development work. Note that you can use audiences and computed traits for this use case if you’re looking for a low-code solution. 

  5. Enriched loyalty analytics: We used Voucherify as a data source to share additional redemption and reward data with Segment and then connected external BI tools to better visualize the data.  

As brands started shifting to modular architecture, Voucherify saw a need to help developers quickly learn the best practices for creating and managing composable loyalty program architectures. That's why Voucherify created the Loyalty Accelerator.

Built on the Next.js framework using React, the Loyalty Accelerator offers an open-source framework to start working on your rewards program.

Resources

Docs: Twilio Segment | Voucherify docs

Loyalty Mobile App GitHub

Loyalty POS GitHub

 

Getting started is easy

Start connecting your data with Segment.