Tier Updates

Real-time Tier Update Notifications

In this tutorial, let's set up Braze to receive loyalty notifications from Open Loyalty and use them to trigger an email campaign. This way, we can inform customers immediately when their tier updates (upgrade or downgrade).

Because the schema of Open Loyalty's webhook requests doesn't match the schema of Braze's API endpoints, we can't send requests to Braze directly. Instead, we rely on Braze's Data Transformation feature to transform the Open Loyalty payload into valid Braze API calls.

Open Loyalty Requirements

  • You are an admin user.

  • You have a Tenant.

  • You have at least one Member profile in Tenant. This profile should also exist in Braze (identified by their e.g. loyaltyCardNumber).

  • You have configured a tier set and defined different tiers.

Braze Requirements

  • You are an account or workspace admin.

  • Access to the "Data Settings" tab in Braze to configure webhook listeners.


Setting up the integration

1

Generate the Webhook URL

First, we must generate a webhook URL to which Open Loyalty can send the notification requests. Braze automatically generates a webhook URL when you create a data transformation.

  1. In Braze, open Data Settings > Data Transformation.

  2. Click Create transformation and configure the following parameters:

    1. Transformation name: Type a name (e.g., "Open Loyalty Tier Update").

    2. Editing experience: Select Start from scratch.

    3. Select destination: Select POST: Track users. (This is the endpoint used to trigger user events).

  3. Click Create Transformation.

  4. Next to Webhook URL, click Copy.

circle-exclamation
2

Create the Webhook Subscription

You must configure Open Loyalty to send data to the Braze URL you just generated whenever a member's tier changes. We will use the CustomerLevelChanged event.

  1. Log in to your Open Loyalty Admin Panel.

  2. Navigate to General > Webhooks.

  3. Click Add new webhook and configure the subscription:

    1. eventName: Set this to CustomerLevelChanged. This event triggers whenever the tier is changed.

    2. url: Paste the Braze webhook URL you copied in Step 1.

    3. Add the following headers:

      1. Content-Type: application/json

      2. User-Agent: partner-OpenLoyalty

  4. Save the webhook subscription.

3

Configure the Data Transformation

Now that Open Loyalty is linked to Braze, you must write the JavaScript logic in Braze to translate the Open Loyalty payload into a Braze User Track event.

  • In Braze, open the data transformation you created in Step 1.

  • Trigger a points change in Open Loyalty (e.g., add points to a test member) to generate a sample payload under Webhook details.

circle-info

The Open Loyalty payload contains a data object with amountChange, amountChangeType, and customer details.

  • Under Transformation code, enter the following JavaScript. This maps Open Loyalty data to Braze properties:

let brazecall = {
  // Update the user's profile attribute with the new tier name
  "attributes": [
    {
      "external_id": payload.data.customer.loyaltyCardNumber,
      "loyalty_tier": payload.data.level.name
    }
  ],
  // Trigger a custom event for the campaign
  "events": [
    {
      "external_id": payload.data.customer.loyaltyCardNumber,
      "name": "Loyalty Tier Changed",
      "time": new Date().toISOString(),
      "properties": {
        "new_tier_name": payload.data.level.name,
        "is_upgrade": payload.data.level.levelMoveUp,
        "is_downgrade": payload.data.level.levelMoveDown
      }
    }
  ]
};

return brazecall;
  • Click Validate to ensure the code runs against your sample payload.

  • Click Activate.

4

Trigger the Email Campaign

You can now use the custom Braze event (Loyalty Tier Changed) to trigger an email.

  1. In Braze, click Campaigns > Create campaign > Email.

  2. In Campaign Name, type a name for your campaign.

  3. In Email Variants, select HTML Editor and click Blank Template.

  4. Click Edit Sending Info and enter a subject line.

  5. Click the Body tab and insert the following HTML code. This uses Liquid logic to display dynamic text based on whether points were added or spent:

{% if event_properties.${is_upgrade} == true %}
  <h1>Congratulations!</h1>
  <p>You've leveled up to <strong>{{event_properties.${new_tier_name}}}</strong> status!</p>
  <p>Check out your new perks in the app.</p>
{% elsif event_properties.${is_downgrade} == true %}
  <p>Your tier status has changed to {{event_properties.${new_tier_name}}}.</p>
  <p>Earn more points to get back to the top!</p>
{% endif %}
  1. Click Done.

  2. In the Schedule Delivery tab, select Action-Based as the delivery type.

  3. In New Trigger Action, select Perform Custom Event and click Add Trigger.

  4. In Choose a custom event, select Loyalty Tier Changed.

  5. Ensure your Target Audience includes the users you are testing with.

  6. Click Launch Campaign.

5

Testing the Setup

To test the setup, manually change a member's tier in Open Loyalty (e.g., via the Admin Panel)

  1. This triggers the CustomerLevelChanged webhook.

  2. Braze receives the data, transforms it using your JavaScript, and records the Loyalty Tier Changed event.

  3. The email campaign is triggered, sending the user an update with their new tier.

Last updated

Was this helpful?