Skip to main content
JavaScript
// If the script is loaded synchronously
Smile.initialize({
  publishableKey: 'pub_0987654321',
  customerToken: 'eyJhbGciOiJIUzI1NiJ9.eyJjdXN0b21lcl9pZGVudGl0eSI6eyJkaXN0aW5jdF9pZCI6IjEwMCJ9LCJleHAiOjE1ODU1OTE1MzZ9.PGJhiM0NYRok5VGAlAOT6F-57gu7SCBaennQbt6YrqU',
  preload: ['pointsSettings']
});

// If the script is loaded asynchronously
document.addEventListener('smile-js-loaded', () => {
  Smile.initialize({
    publishableKey: 'pub_0987654321',
    customerToken: 'eyJhbGciOiJIUzI1NiJ9.eyJjdXN0b21lcl9pZGVudGl0eSI6eyJkaXN0aW5jdF9pZCI6IjEwMCJ9LCJleHAiOjE1ODU1OTE1MzZ9.PGJhiM0NYRok5VGAlAOT6F-57gu7SCBaennQbt6YrqU',
    preload: ['pointsSettings']
  });
});
This async method initializes the SDK with information about the loyalty program and the currently logged-in customer. This method must be called before you can interact with other methods provided by the SDK.
If you’re loading the SDK script asynchronously, you should wrap your initialization code with a loaded event to ensure it doesn’t encounter an error due to the script not yet being present on the page.

Parameters

options
object
required

Returns

This method returns a Promise that:
  • On success, resolves to void. The SDK will be initialized and ready for use.
  • On failure, rejects with an error object.
If the method is improperly invoked (e.g. missing publishableKey), the Promise will be rejected.