This document provides guidance on detecting different modal events, enabling you to run custom actions.
Make sure you have the Voyage Global Tag installed
Retrieve Subscriber Identifier
Determine whether the visitor is already a subscriber (e.g. for showing a custom modal)
// voyage.getSubscriberCampaignId() : Promise<string|undefined>
voyage.getSubscriberCampaignId().then(subscriberCampaignId => {
// add your code here
});
Modal Events
Detect a particular modal event and trigger your custom action
- close - when a modal is closed
- click - when a call-to-action button on a modal is selected
- subscribe - when a phone number is subscribed
// voyage.modal.on(eventName: 'close' | 'click' | 'subscribe', callback: () => void)
voyage.modal.on("close", () ⇒ {});
voyage.modal.on("click", () ⇒ {});
voyage.modal.on("subscribe", () ⇒ {});
Detect whether the Voyage modal will be displayed for a user
// voyage.modal.hasShown() : Promise<boolean>
voyage.modal.hasShown().then(modalHasShown => {
if (!modalHasShown) {
// add your code here
}
}