Skip to main content

Popup widget view changed

This event is triggered when the view of the popup widget is changed. It provides details about the new view that is displayed.

Event details​

When the popUpWidgetViewChanged event is triggered, the received event.detail object includes the following properties:

Usage example​

Before listening for the popupWidgetViewChanged event, ensure the SDK and the Rewards module are ready:

function subscribeToPopupWidgetViewChanged() {
const eventName = window.gw.sdk.rewards.events.POPUP_WIDGET_VIEW_CHANGED;

window.gw.sdk.on(eventName, (event) => {
console.log(event.detail);
});
}

function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.REWARDS;

window.gw.sdk.runIfModuleReady(moduleName, () => {
subscribeToPopupWidgetViewChanged();
});
}

if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}

// Example output:
// {type: 'popupWidgetViewChanged', view: 'home'}

This code ensures the SDK and the Rewards module are ready before setting up the event listener, allowing you to respond when the popup widget view changes and access the relevant details.

Possible view values​

The view property can be one of the following values:

  • home — Home view of the popup widget
  • ways_to_earn — Ways to earn points view
  • ways_to_redeem — Ways to redeem points view
  • referral — Referral program view
  • vip_tiers — VIP tiers view