Techdocs
Search…
Popup Callbacks
The JS API can be used to register callbacks to hook into the popup events. To register listener to a callback, use api.listen(callbackId, callbackFunction) function.

Email Given Callback

Whenever customer has input their email address into a Nosto behavioral pop-up that asked whether they want to subscribe to an email newsletter.
1
nostojs(function(api){
2
api.listen("emailgiven", function(emailSubscriptionEvent) {
3
console.log(emailSubscriptionEvent.email);
4
console.log(emailSubscriptionEvent.newsletter);
5
});
6
});
Copied!

Fields

Field
Type
Reason
email
String
The email address in the user input.
newsletter
String
Whether the user gave their consent to subscribing to a newsletter. E.g. either the pop­up prompting for the email address input was worded similarly to “Please enter your email address to subscribe to our newsletter:” or there was an explicit checkbox that the user checked to give their consent.

Popup Opened Callback

1
api.listen("popupOpened", function(popupEvent) {
2
if (popupEvent.error) {
3
console.error(popupEvent.error);
4
} else {
5
console.log(popupEvent.campaignId);
6
console.log(popupEvent.type);
7
}
8
});
Copied!

Fields

Field
Type
Reason
campaignId
String
The identifier of the popup campaign
type
String
The trigger-type of the popup campaign
error
String
Description of the error in the case the pop-up failed to open.

Popup Ribbon Callback

The customer can minimize a Nosto behavioral pop-up into a ribbon to be shown at the edge of the viewport. The pop-up is also changed to be shown in its minimized ribbon form after a page load is done after a pop-up has been shown.
This callback will be called whenever the ribbon is rendered onto screen after a page load.
1
api.listen("popupRibbonShown", function(ribbonEvent) {
2
console.log(ribbonEvent.campaignId);
3
});
Copied!

Fields

Field
Type
Reason
campaignId
String
The identifier of the popup campaign

Popup Minimised Callback

The customer can minimize a Nosto behavioral pop-up into a ribbon to be shown at the edge of the viewport. This callback will be called when the customer clicks the minimize button on the pop-up.
1
api.listen("popupMinimized", function(popupEvent) {
2
console.log(popupEvent.campaignId);
3
});
Copied!

Fields

Field
Type
Reason
campaignId
String
The identifier of the popup campaign

Popup Maximised Callback

The customer can minimize a Nosto behavioral pop-up into a ribbon to be shown at the edge of the viewport. When they click on this ribbon, the pop-up will be maximized again to be shown in full size. This callback will be called when the customer clicks the ribbon to maximize the pop-up.
1
api.listen("popupMaximized", function(popupEvent) {
2
console.log(popupEvent.campaignId);
3
});
Copied!

Fields

Field
Type
Reason
campaignId
String
The identifier of the popup campaign

Popup Closed Callback

The customer can click a “close permanently” button or link in a Nosto behavioral pop-up to dismiss the pop-up permanently. This callback is called when the customer clicks on that button or link.
1
api.listen("popupClosed", function(popupEvent) {
2
console.log(popupEvent.campaignId);
3
});
Copied!

Fields

Field
Type
Reason
campaignId
String
The identifier of the popup campaign

Coupon Given Callback

The callback will be called when a customer clicks a button inside a Nosto behavioral pop-up to get their discount coupon code.
1
api.listen("couponGiven", function(couponEvent) {
2
if (couponEvent.error) {
3
console.error(couponEvent.error);
4
} else {
5
console.log(couponEvent.campaignId);
6
console.log(couponEvent.couponCode);
7
console.log(couponEvent.origin);
8
}
9
});
Copied!

Fields

Field
Type
Reason
campaignId
String
The identifier of the popup campaign.
couponCode
String
The trigger-type of the popup campaign.
origin
String
Where the coupon code originated from. Always popup.
error
String
Description of the error in the case the pop-up failed to open.

Cart Abandonment Callback

The callback will be called when a customer clicks a button inside a Nosto abandoned cart pop-up to get an abandoned cart email.
1
api.listen("sendabandonedcartemail", function(sendMailEvent) {
2
if (!sendMailEvent.sent) {
3
console.error(sendMailEvent.message);
4
} else {
5
console.log(sendMailEvent.campaignId);
6
console.log(sendMailEvent.email);
7
}
8
});
Copied!

Fields

Field
Type
Reason
sent
boolean
A boolean indicating whether the email was sent
campaignId
String
The identifier of the popup campaign
email
String
The email address to which the email was sent
message
String
Any error messages relating to the email sending
Last modified 1yr ago