The Custom Subscription Popup is configured with the subscribePopup parameter of the Web SDK init call, and it is shown or hidden through its module instance.
Note: the Custom Subscription Popup is a legacy widget. For new integrations use the Subscription widget, which has a manual trigger (Pushwoosh.moduleRegistry.subscriptionWidget.show()) and replaces this popup once its prompt or bell is turned on. The steps below apply to a subscribePopup already on your site.
1. Enable manual triggering. Set manualToggle: true inside subscribePopup so the popup does not appear automatically on page load:
Pushwoosh.push(['init', {
applicationCode: 'XXXXX-XXXXX',
// ... other init options ...
subscribePopup: {
enable: true,
manualToggle: true,
text: 'Enable notifications to receive our latest updates and offers.',
confirmSubscriptionButtonText: 'Subscribe',
askLaterButtonText: 'Not now'
}
}]);
2. Show the popup on demand. The popup instance is exposed as Pushwoosh.moduleRegistry.subscribePopup and provides a toggle() method. The instance exists only after the subscribe-popup-ready event has fired. It is not created if the user is already subscribed or if the browser permission is already granted or denied:
Pushwoosh.addEventHandler('subscribe-popup-ready', function () {
document.getElementById('mySubscribeButton').addEventListener('click', function () {
Pushwoosh.moduleRegistry.subscribePopup.toggle(true); // show
});
});
// toggle() - flips visibility
// toggle(true) - shows the popup
// toggle(false) - hides the popup
Note: Pushwoosh.subscribe() is a different method — it asks for the native browser permission directly and resolves with no value. It does not display the Custom Subscription Popup.
Re-subscription behaviour. Browsers cap how often the native permission prompt can appear, but the exact rule is not "twice, then permanent": in Chrome, once the prompt has been dismissed (closed without a choice) three times, Chrome temporarily stops showing it for that site; a single explicit Block click, on the other hand, blocks the origin until the user manually resets the permission in site settings. The Custom Subscription Popup is not subject to the browser's limit on dismissed prompts — you can display it as many times as needed until the user subscribes or the browser permission is blocked. That makes it a good entry point for a "Subscribe" button, including cases such as an HTML5 canvas game where the native prompt must be triggered by a real interaction with a DOM element. When the user presses the popup's Subscribe button, the native permission prompt appears.
To track interactions, handle the subscribe-popup-show, subscribe-popup-accept and subscribe-popup-decline events. See the Custom Subscription Popup documentation for the full parameter list.
Comments
0 comments
Please sign in to leave a comment.