JavaScript SDK
The Mage JavaScript SDK is a lightweight client-side library that lets you build custom loyalty experiences directly in your storefront. Once enabled, the SDK is bundled into your storefront and available aswindow.MageSDK.
Enable the SDK
Enable the Mage JavaScript SDK from the merchant dashboard under Settings > Developer. Once enabled, the SDK is automatically injected into your storefront.Initialization
The SDK loads asynchronously. Use themage-sdk-loaded event to ensure it’s ready before calling any methods:
Response format
Most methods return a consistent response shape: Success:updateCustomerDob is the one exception. It returns a plain boolean rather than the wrapped response shape, for backwards compatibility.Loyalty modes
A shop runs in one of two loyalty modes, set by the merchant:pointsThe loyalty balance is plain points, so450means 450 points.store_creditThe balance is Mage store credit, denominated in money. Every loyalty number the SDK returns (points,pointsCost, balances) is in the currency’s minor units, so450means$4.50.
loyaltyMode and currency. Pass both to the built-in formatLoyaltyValue helper and it renders correctly in either mode, so your code stays mode-agnostic. See the Loyalty modes guide for the full picture, including how redemption differs.
Common errors
Available methods
Customers
Customer details, VIP tier, activity feed, and profile updates
Rewards
List rewards, view redeemed rewards, and redeem points or store credit
VIP Tiers
List all VIP tier configurations
Earning Rules
List active earning rules with tier and campaign boosts
Referrals
Referral stats, links, and social sharing
Loyalty modes
Format and redeem correctly in points and store-credit shops
Sidebar
Programmatically open and close the loyalty sidebar