Getting started

You can interact with the LoyaltyLion SDK using its JavaScript API. You can use this to initialize and authenticate the SDK, configure various settings, and listen to events emitted when customers take various actions.


The LoyaltyLion SDK adds itself to the window.loyaltylion variable.

Initialization

loyaltylion.init is called automatically for Shopify, BigCommerce and Magento installations.

loyaltylion.init should be called once per page load to initialize the LoyaltyLion SDK and (if applicable) authenticate the current logged in customer. You’ll need your LoyaltyLion site token to identify your store.

Initialize example (without customer)

loyaltylion.init({
  token: 'YOUR_SITE_TOKEN',
})

If a customer is logged in, their information and authentication data should be passed in, using a server-side generated auth token.

Initialize example (with Customer)

loyaltylion.init({
  token: 'YOUR_SITE_TOKEN',
  customer: {
    id: '1001', // unique customer ID
    email: 'alice@example.com', // customer email address
  },
  auth: {
    date: '2018-01-01T10:00:00Z', // date in ISO8601 format
    token: 'AUTH_TOKEN', // token, generated server-side
  },
})