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.
UserAttributes are used for segmentation. They follow the given structure:
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.
Sandbox
Code
/* interface */
interface IStaticImage {
typeId: "STATIC";
src: string;
action: IAction; // <- on click action
}
/* example #1: on click redirect */
const content: IStaticImage = {
typeId: "STATIC",
src: "https://uploads-ssl.webflow.com/60ae16f0e20bce50d40c3c7e/61efce5c2ab738e60fd0856f_Group%2027.png",
action: {
type: "REDIRECT",
data: {
url: "https://website.com/rewards"
}
}
}
/* example #2: on click open wallet in a pop up */
const content: IStaticImage = {
typeId: "STATIC",
src: "https://uploads-ssl.webflow.com/60ae16f0e20bce50d40c3c7e/61efce5c2ab738e60fd0856f_Group%2027.png",
action: {
type: "TOGGLE_FRAME_CONTENT";
id: string;
container: {
typeId: "POP_UP",
css: `
.__glu_container {
border-radius: 10px;
background-color: #000;
cursor: pointer;
}
`},
content: {
typeId: "WALLET"
}
}
}
/* example #3: on click open a campaign in a bottom sheet */
const content: IStaticImage = {
typeId: "STATIC",
src: "https://uploads-ssl.webflow.com/60ae16f0e20bce50d40c3c7e/61efce5c2ab738e60fd0856f_Group%2027.png",
action: {
type: "TOGGLE_FRAME_CONTENT";
id: string;
container: {
typeId: "BOTTOM_SHEET",
css: `
.__glu_container {
border-radius: 10px;
background-color: #000;
cursor: pointer;
}
`},
content: {
typeId: "CAMPAIGN",
conditions: {
campaignId: ["asd283mkla-3890njakd-jkandsk3-kjadnjk3"]
}
}
}
}
Close
The glu.open method returns a unique string. Following method can be used to close the frame:
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.
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.