Paste the given snippet in your websiteβs HTML file just before closing the body (</body> ) tag.
Replace the variables with correct values.
You are now ready to load CustomerGlu UI on your website. You can now use:
The Nudges section on the dashboard to add dynamic entrypoints like floating launchers, popups, banners, etc.
The subsequent SDK Functionality to programmatically load campaigns.
Functionality
On pasting the above script, a global instance glu will be available in the window.
The glu instance supports the given methods:
Register User
Use the given method to register a user with CustomerGlu:
β οΈwriteKey is a string that will be provided by CustomerGlu.
UserIdentification follows the given structure:
If the user is not logged in the platform, userId can be null, and anonymousId can be passed (an anonympusId will be auto-assigned if not passed explicitly). User progress/state of the campaigns will be linked to the anonymousId
After the user logs in, the same anonymousId and the userId can be passed. And progress linked to anonymousId will be linked with the userId. If user is already logged in, userId can be passed directly.
β οΈ At least one function call with both - anonymousId and userId is required to map the anonymousId to the userId after the user logs in.
UserAttributes are used for segmentation. They follow the given structure:
customAttributes can hold any extra key-value pair that might be used for user segmentation/other purposes. Example: {"location":"Mumbai""}
Open
The given function can be used to render CustomerGlu UI fragments on the screen:
β οΈ It returns the promise of a string, that can be used to close the UI using glu.close method.
container holds the container details. i.e. If the UI is a bottom sheet, pop up or be embedded etc.
The styling of the container can be customised using the css property present in each container type. The container elements are targeted using special class names.
Different containers can have same class names for styling, but the styles gets scoped to only the targeted container.
Media queries and your custom CSS variables can also be used inside the string.
All supported container types are listed down below:
conditions property inside the ICampaign is in key-value pair format. Key is the property that needs to be filtered for. Value is an array of acceptable set of values.
The first campaign that satisfies all the conditions is selected.
If the campaign is not found, an error CAMPAIGN_NOT_FOUND is thrown.
glu.getCampaignDetails can be used to get the campaign details. The result include the campaign details and the array of rewards earned for that campaign.
It accepts 2 arguments: filter and config
filter helps in identifying the campaign for which the details are needed.
config has configurations like: should the reward details also exist with the details of the campaign.
You can listen to the analytics events triggered from the glu ui by registering a callback with the SDKβs addAnalyticsListener method.
glu.addAnalyticsListener accepts a callback function as an argument. & whenever an analytics event is triggered, it is passed on to the callback as the first argument.