This is used to explicitly trigger an Opt-in box for subscribing the user to push notifications.
Parameters
1) triggerOptIn: Command to trigger the opt-in box for subscribing the user to push notifications.
2) settingsObject: (Type: Dictionary, Optional):
Contents of 'Settings Object' Dictionary:
i) Subscriber Segment (Type: String, Optional, Default: 'global' (default subscriber segment)) - This will add the subscriber to the segment specified.
ii) Modal box (with logo and text) to explain the rationale: (Type: Dictionary, Optional) - If this parameter is not specified, modal will not be shown.
This parameter is used only in case of HTTPS implementations. In case of HTTP implementations, a custom opt-in box is shown instead of the modal.
Contents of 'Modal box' Dictionary:
a) Text (Type: String, Optional) - This text will be shown in the modal box. Default text will be shown if this parameter is not specified.
Default: “Please click ‘Allow’ to receive push notifications from {company name}”.
b) Blacken background. (Type: Boolean, Default: true) - This will blacken the page background, outside the modal box, if set to true.
3) HTTPWindowOnly (Type: Boolean, Optional, Default: false)
This is only applicable for HTTP implementations. If this is set to True, the child window which subscribes users to push notifications, will open directly without opening the custom opt-in box.
Functionality:
i) If User is not subscribed
For HTTPS implementations:
Shows the Chrome Native opt-in box
Shows the modal box (that says please subscribe)(if 'modal' parameter is passed)
Blackens the background
For HTTP implementations:
Shows the custom opt-in box
Blackens the background
ii) If User is already subscribed
Shows modal box with logo and text. Default :“You are already subscribed to push notifications” (if 'modal' parameter is passed)
iii) If User had blocked
Shows modal box with logo, and text. Default: “Uh-oh! You seem to have blocked the notifications last time you came on our website. To see how to subscribe, Click Here". (if 'modal' parameter is passed)
Example code
window._pcq.push(['triggerOptIn',{subscriberSegment: 'homepage', modal: {text: 'Get instant alerts from our website. Please subscribe.', blackenBackground: true}, httpWindowOnly: true}]);
//Examples for HTTPS Implementations
//Examples for HTTPS Implementations
window._pcq.push(['triggerOptIn',{subscriberSegment: 'homepage', modal: {text: 'Get instant alerts from our website. Please subscribe.', blackenBackground: true}}]); //Calls triggerOptIn with custom text, blackened background and segment as 'homepage'
window._pcq.push(['triggerOptIn',{subscriberSegment: 'homepage', modal: {text: 'Get instant alerts from our website. Please subscribe.', blackenBackground: true}}]); //Calls triggerOptIn with default text, blackened background and segment and default segment as 'homepage'
window._pcq.push(['triggerOptIn', {subscriberSegment: 'homepage'}]); //Calls triggerOptIn without modal and default segment as 'homepage'
window._pcq.push(['triggerOptIn']); //Calls triggerOptIn with default text and default segment(global)
//Examples for HTTP Implementations
//Examples for HTTP Implementations
window._pcq.push(['triggerOptIn',{subscriberSegment: 'homepage'}]);//Calls triggerOptIn with segment as 'homepage'
window._pcq.push(['triggerOptIn',{subscriberSegment: 'homepage', httpWindowOnly: true}]); //Calls triggerOptIn with segment as 'homepage' and with child window only. Custom Opt-in will not open in this case.
window._pcq.push(['triggerOptIn',{httpWindowOnly: true}]); //Calls triggerOptIn with default segment(global) and with child window only. Custom Opt-in will not open in this case.