JavaScript

Run CustomerGlu offers, campaigns, games, and rewards on websites with a simple SDK.

1. Quick Start

  • Include the below script in your HTML file.

<script src="https://amplify-launcher.dgdcnmnewfrib.amplifyapp.com/assets/scripts/sdk.js"></script>
  • Create CustomerGlu object right below the script.

<script src="https://amplify-launcher.dgdcnmnewfrib.amplifyapp.com/assets/scripts/sdk.js"></script>
<script>
var clientId = "CLIENT_ID"; // REQUIRED
var userId = null; // OPTIONAL, uses browser session ID to track user
var glu = new CustomerGlu(clientId, userId); // Initilize CustomerGlu
</script>
  • USER_ID is optional if the user has not logged in. A SESSION_ID would be created to track the user.

Playground

CodeSandbox - https://codesandbox.io/s/bold-kapitsa-6rejy

CodePen - https://codepen.io/suhas_is_a_pen/pen/poNdvgr

2. CustomerGlu SDK Configurations

  • A client can specify the following configuration values

export ClientConfig {
launcherExcludeList: [], // Paths where launcher is not shown
fullPageWalletIncludeList: ["/rewards.html"], // Paths where full page wallet should be shown
fullPageWalletHook: "#app", // HTML element that should hold the full page wallet
};

launcherExcludeList - URLs where you don't want CustomerGlu launcher to show up.

fullPageWalletIncludeList - URLs where you want CustomerGlu to embed its rewards wallet.

fullPageWalletHook - HTML element identifier, place on the page where the CustomerGlu rewards wallet will be shown.

Demo

CodeSandBox - https://codesandbox.io/s/bold-kapitsa-6rejy?file=/rewards.html

Example Wallet

3. Documentation

1. Class CustomerGlu

1.1 Constructor - CustomerGlu(clientId: string, userId?: string);

1.2 Method: setUserId(userId: string) -

  • In Single Page Application, if userId is available after initializing the SDK, use this method to reset the userId.