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 Adobe Commerce 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',
})

loyaltylion.init should only ever been called once per page load. Calling this method more than once throws an exception error and result in a slower user experience.

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', // site token
  customer: {
    id: '1001', // unique customer ID
    email: 'alice@example.com', // customer email address
  },
  auth: {
    date: '2018-01-01T10:00:00Z', // date in ISO 8601 format
    token: 'AUTH_TOKEN', // token, generated server-side, different than the site token
  },
})