Loyalty

Loyalty Variables

Loyalty variables represent loyalty program data returned from the loyalty integration. The structure includes customer information, points balance, available rewards, activities, and tier information.

Customer Information

PropertyTypeDescriptionExampleAvailability
loyalty.customer.idString"123456789"Always
loyalty.customer.emailStringCustomer email"[email protected]"Always
loyalty.customer.externalIdString"123456789"Always
loyalty.customer.balanceNumberAmount available to redeem for rewards500Always
loyalty.customer.totalPointsNumberAll points earned, including redeemed ones.1000Always
loyalty.customer.phoneNumberString"1234567890"If Available
loyalty.customer.firstNameStringCustomer first name"John"If Available
loyalty.customer.lastNameStringCustomer last name"Doe"If Available
loyalty.customer.claimedRewardsArrayRewards the customer has already redeemed.[{ "id": "123456", "code": "WELCOME10", ... }]If Available

Customer Claimed Rewards loyalty.customer.claimedRewards[]

loyalty.customer.idStringDescription"123456789"Always
rewardIdStringReward Id"1234"Always
codeStringDiscount code"WELCOME10"Always
isUsableNumbertrue if the reward can still be used, false otherwise.500Always
customAttributesNumberhistory (object) Raw customer data from the loyalty provider.Always

Customer Custom Attributes (Provider-specific)

PropertyTypeExampleAvailability
loyalty.customer.customAttributesObjectRaw customer data from Loyalty ProviderAlways

Rewards

Property

Type

Example

Availability

loyalty.rewards

Array

[{ "id": "123456", ... }]

Always

loyalty.rewards[].id

String

"123456"

Always

loyalty.rewards[].description

String

"50 points"

Always

loyalty.rewards[].name

String

"$5 voucher"

Always

loyalty.rewards[].pointsCost

Number

50

Always

loyalty.rewards[].type

String

Provider-Specific Reward Types (e.g.):

Loyalty Lion: "cart_discount_voucher", "product_cart", "free_shipping_voucher"...

Yotpo: "product", "product_variable"...

Always

loyalty.rewards[].isAvailable

Boolean

true

Always

Rewards Custom Attributes (Provider-specific)

PropertyTypeExampleAvailability
loyalty.rewards.customAttributesObjectRaw reward data from Loyalty ProviderAlways

History

PropertyTypeExampleAvailability
loyalty.historyArray[{ "title": "Purchase", ... }]If Available
loyalty.history[].titleString"Purchase"Always
loyalty.history[].createdAtDate"2024-01-15T10:30:00Z"Always
loyalty.history[].completedAtDate"2024-01-15T10:30:00Z"Always
loyalty.history[].pointsNumber100Alway

Activities

PropertyTypeExampleAvailability
loyalty.activitiesArray[{ "id": "123456", ... }]Always
loyalty.activities[].idString"123456"Always
loyalty.activities[].typeString"purchase" | "join_program" | "pageview" | "custom" | "instagram_follow" | "facebook_like" | "birthday" | "referralAlways
loyalty.activities[].customerIdString"customer_123"Always
loyalty.activities[].action_nameString"download_the_app"Always
loyalty.activities[].titleString"Download the App"Always
loyalty.activities[].detailsString"100 points"Always
loyalty.activities[].reward_textString"100 points"Always
loyalty.activities[].cta_textString"Download the App"Always
loyalty.activities[].iconString"mobile"Always
loyalty.activities[].urlString"https://appstore.com/app"If Available
loyalty.activities[].max_completions_per_userNumber1Always
loyalty.activities[].min_actions_requiredNumber1Always

Activity Status loyalty.activities[].status

PropertyTypeDescriptionExampleAvailability
customer_actions_completedNumberNumber of actions the customer has completed toward a multi-step campaign. Only applies to campaigns with more than one step.1Always
customer_minutes_until_next_actionNumberHow long (in minutes) the customer must wait before they can take the next eligible action.0Always
customer_minutes_until_next_completionNumberHow long (in minutes) the customer must wait before they can complete the campaign again.0Always
customer_times_completedNumberNumber of times the customer has fully completed a campaign and earned the reward. A value of 1 means it was completed once.1Always
global_completions_leftNumberNumber of completions remaining for the campaign globally (if there's a limit for all users).0Always

Activities Custom Attributes (Provider-specific)

PropertyTypeExampleAvailability
loyalty.activities.customAttributesObjectRaw activity data from Loyalty ProviderAlways

Tiers

PropertyTypeExampleAvailability
loyalty.tiersArray[{ "id": "12345", ... }]Always
loyalty.tiers[].idString"12345"Always
loyalty.tiers[].nameString"Bronze"Always
loyalty.tiers[].levelNumber1Always
loyalty.tiers[].isActiveBooleanfalseAlways
loyalty.tiers[].benefitsArray["Free Shipping", "Priority Support"]Always

Tier Requirements

PropertyTypeExampleAvailability
loyalty.tiers[].requirementsArray[{ "type": "points", ... }]Always
loyalty.tiers[].requirements[].typeString"points"Always
loyalty.tiers[].requirements[].thresholdNumber0Always
loyalty.tiers[].requirements[].progressNumber100Always

Sample Loyalty Response

{
  "customer": {
    "id": "customer_123",
    "email": "[email protected]",
    "externalId": "loyalty_customer_id",
    "balance": 500,
    "totalPoints": 1000,
    "customAttributes": {
      "third_party_id": "customer_123",
      "email": "[email protected]",
      "first_name": "John",
      "last_name": "Doe",
      "phone_number": "+1234567890",
      "points_balance": 500,
      "points_earned": 1000,
      "vip_tier_name": "Gold",
      "vip_tier_actions_completed": {
        "points_earned": 750
      },
      "amount_spent_cents_in_customer_currency": 50000,
      "purchases_made": 3,
      "referrals_completed": 1,
      "history_items": [
        {
          "action": "Purchase",
          "created_at": "2024-01-15T10:30:00Z",
          "completed_at": "2024-01-15T10:30:00Z",
          "points": 100,
          "redemption_option_id": null,
          "status": "Completed"
        }
      ]
    }
  },
  "history": [
    {
      "title": "Purchase",
      "createdAt": "2024-01-15T10:30:00Z",
      "completedAt": "2024-01-15T10:30:00Z",
      "points": 100,
      "customAttributes": {
        "action": "Purchase",
        "created_at": "2024-01-15T10:30:00Z",
        "completed_at": "2024-01-15T10:30:00Z",
        "points": 100
      }
    }
  ],
  "rewards": [
    {
      "id": "reward_789",
      "name": "$10 Off Purchase",
      "description": "Get $10 off your next purchase",
      "pointsCost": 1000,
      "type": "discount",
      "isAvailable": false,
      "customAttributes": {
        "id": "reward_789",
        "name": "$10 Off Purchase",
        "description": "Get $10 off your next purchase",
        "amount": 1000,
        "discount_type": "discount",
        "variant_id": null
      }
    }
  ],
  "activities": [
    {
      "id": "activity_123",
      "type": "CustomAction",
      "customerId": "customer_123",
      "display_order": "1",
      "action_name": "download_the_app",
      "max_completions_per_user": 1,
      "min_actions_required": 1,
      "status": {
        "customer_actions_completed": 1,
        "customer_minutes_until_next_action": null,
        "customer_minutes_until_next_completion": null,
        "customer_times_completed": 1,
        "global_completions_left": 999
      },
      "createdAt": "2024-01-01T00:00:00Z",
      "title": "Download Our App",
      "details": "Download our mobile app to earn points",
      "reward_text": "Earn 50 points",
      "cta_text": "Download Now",
      "icon": "mobile",
      "url": "https://appstore.com/app",
      "customAttributes": {}
    }
  ],
  "tiers": [
    {
      "id": "tier_1",
      "name": "Bronze",
      "level": 1,
      "requirements": [
        {
          "type": "points",
          "threshold": 0,
          "progress": 500
        },
        {
          "type": "orders",
          "threshold": 1,
          "progress": 3
        }
      ],
      "benefits": ["Free Shipping", "Priority Support"],
      "isActive": false,
      "customAttributes": {}
    },
    {
      "id": "tier_2",
      "name": "Gold",
      "level": 2,
      "requirements": [
        {
          "type": "points",
          "threshold": 1000,
          "progress": 500
        },
        {
          "type": "amountSpent",
          "threshold": 10000,
          "progress": 50000
        }
      ],
      "benefits": ["Free Shipping", "Priority Support", "Exclusive Discounts"],
      "isActive": true,
      "customAttributes": {}
    }
  ]
}
⚠️

Important Notes

  • The loyalty data is automatically populated when a customer accesses the app when logged in
  • The activity with action_name "download_the_app" is automatically recorded when the customer uses the mobile app
  • The activity with action_name "enable_push_notifications" will initiate request for the customer to enable push notifications when selected in the mobile app
  • All custom attributes contain provider-specific data that may vary based on your loyalty program configuration
  • Points balance and rewards availability are calculated in real-time based on the customer's current status
  • Tier requirements include different types: "points", "orders", "referrals", and "amountSpent"
  • Some features may not be supported depending on Loyalty Providers which include:
    • Yotpo
    • Loyalty Lion
    • Smile
    • Rivo