Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Checking Web Push supportability

Subscribe to the "Back in Stock" trigger

Method Objective

The method

allows checking if Web Push is available in the browser. WarningWeb Push Notifications don't work in incognito mode. The method will give a false result when the browser is in that mode

subscribes the user to the notifications that the product is available.

Tip

You don't need to check for Web Push support, permission availability, or request it from the user. This method will do everything you need by itself.

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("subscriptionsubscribe_trigger", "webproduct_push_supportedavailable", callbackparams);

ValueTypeThe result of checking Web Push supportbooleanExample
NameTypeRequirementDescription
callbackfunctionrequiredIt's a callback function that takes a boolean value of the check result as a parameter.

API response

paramsObjectrequiredObject with request parameters.

Request parameters

NameTypeRequirementDescription
itemnumber/stringrequiredThe product ID to notify of the product availability the user will be subscribed.
emailstringoptionallyThe current user's Email. If not set, the subscription will be on Web Push notification.
webpushbooleanoptionallyThis property, if true, additionally adds the Web Push notification subscription for the specified product.
propertiesObjectoptionally

Additional product properties. The following are available:

  • fashion_size (number/string) - clothing size. The value of the parameter in the internal format of the store.

Examples of use

Code Block
languagejs
themeFadeToGrey
// subscribing to both channels: Email and Web Push Notifications
personaclick("subscriptionsubscribe_trigger", "web_push_supported", function(supported)product_available", {
    item: "100500", 
    email: "john.doe@examplestore.com",
    webpush: true,
    properties: {
    if (supported) {  fashion_size: "XL"
    }
});

Code Block
languagejs
themeFadeToGrey
// ifsubscribing to WebEmail PushNotification is supported
 only
personaclick("subscribe_trigger", "product_available", {
  } else {
item: "100500", 
    email: "john.doe@examplestore.com"
});

Code Block
languagejs
themeFadeToGrey
// ifsubscribing to Web Push isn't supported Notification only
personaclick("subscribe_trigger", "product_available", {
    item: }"100500"
});
Checking permission status

Unsubscribe from the "Back in Stock" trigger

Method Objective

The method checks if the user has permitted to show Web Push notificationsunsubscribes the user from the notification that the product is available.

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("subscriptionunsubscribe_trigger", "webproduct_push_subscribedavailable", callbackparams);

ValueTypeThe result of the permission checkbooleanExample
NameTypeRequirementDescription
callbackparamsfunctionObjectrequiredIt's a callback function that takes a boolean value of the check result as a parameter.

API response

Object with request parameters.

Request parameters

NameTypeRequirementDescription
item_idsarrayrequiredAn array of product IDs for which the user would like to unsubscribe from the product availability notification. You can use an empty array to unsubscribe from all products.
emailstringrequiredThe current user's Email.

Examples of use

Code Block
languagejs
themeFadeToGrey
personaclick("subscriptionunsubscribe_trigger", "webproduct_push_subscribedavailable", function(subscibed) {
    if (subscibed) {
item_ids: ["100500", "146", "12"], 
      // if the user has permitted Web Push notifications
    } elseemail: "john.doe@examplestore.com"
});

Code Block
languagejs
themeFadeToGrey
personaclick("unsubscribe_trigger", "product_available", {
    item_ids: [],   // ifunsubscribe thefrom userall hasn'tproducts
yet permitted Web Push notifications or has rejected the request
    }
});
Getting user permission
email: "john.doe@examplestore.com"
});


Checking the "Back in Stock" trigger subscription

Method Objective

The method allows subscribing the user to Web Push notifications using only the system permissions window in the browser.

Tip

We recommend using the Programmatic Pop-Ups tool for more flexibility in configuring the user's subscription to Web Push notifications.

checking the subscription status of the "Back in Stock" trigger.

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("subscriptioncheck_trigger", "webproduct_push_subscribeavailable", callbackparams, success, error);


ValueTypeThe result of subscriptionboolean
NameTypeRequirementDescription
callbackfunctionrequiredIt's a callback function that takes a boolean value of the user's subscription result.

API response

paramsObjectrequiredObject with request parameters.
successFunctionrequiredCallback-function, where the API response will be passed to. Response type: object.
errorFunctionoptionallyCallback-function to be called when an error occurs (any HTTP status code other than 200).

Request parameters

NameTypeRequirementDescription
itemstring/numberrequiredProduct ID
emailstringoptionallyEmail for subscription checking
phonestringoptionallyPhone for subscription checking
loyalty_idstringoptionallyLoyalty ID for subscription checking


Note

If no email, phone, or loyalty_id is specified, only the user's current device will be checked. It won't take into account subscriptions performed on the user's other devices.

API response properties

NameTypeDescription
statusbooleanShows whether or not there is a trigger subscription for the product

Example of use

Code Block
languagejs
themeFadeToGrey
personaclick("subscriptioncheck_trigger", "web_push_subscribe"product_available", {item: "100500", email: "john.doe@examplestore.com"}, function(subscibedresponse) {
    if (response.status) {
  (subscibed)       console.log("Subscribed!");
    } else {
        console.log("Not subscribed!");
    }
}, function(error) {
  // if the user has subscribed to Web Push notifications request failed.
});


Code Block
languagejs
themeFadeToGrey
personaclick("check_trigger", "product_available", {item: "100500"}, function(response) {
    if (response.status) {
        console.log("Subscribed!");
    } else {
        console.log("Not subscribed!");
// if the user rejects}
the Web Push notification subscription
    }}, function(error) {
  // if the request failed
});


Subscribe to the "

Back in Stock

Price Drop" trigger

Method Objective

The method subscribes the user to the notifications of a notification that the product is availableproduct price decrease.

Tip

You don't need to check for Web Push support, permission availability, or request it from the user using the methods available here. This method will do everything you need by itself.

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("subscribe_trigger", "product_price_availabledecrease", params);

NameTypeRequirementDescription
paramsObjectrequiredObject with request parameters.

Request parameters

NameTypeRequirementDescription
iditemnumber/stringrequiredThe product ID to notify of the product availability price drop the user will be subscribed.
pricenumberrequiredThe current product price.
Example
emailstringoptionallyThe current user's Email. If not set, the subscription will be on Web Push notification.
webpushbooleanoptionallyThis property, if true, additionally adds the Web Push notification subscription for the specified product.

Examples of use

Code Block
languagejs
themeFadeToGrey
// subscribing to both channels: Email and Web Push Notifications
personaclick("subscribe_trigger", "product_availableprice_decrease", {
    item: "100500", 
    price: 146.55, 
    email: "john.doe@examplestore.com",
    webpush: true
});

Code Block
languagejs
themeFadeToGrey
// subscribing to Email Notification only
personaclick("subscribe_trigger", "product_price_decrease", {id
    item: "100500", 
    price: 146.55, 
    email: "john.doe@examplestore.com"
});
Subscribe to

Code Block
languagejs
themeFadeToGrey
// subscribing to Web Push Notification only
personaclick("subscribe_trigger", "product_price_decrease", {
    item: "100500", 
    price: 146.55 
});


Unsubscribe from the "Price Drop" trigger

Method Objective

The method subscribes unsubscribes the user to a from an email notification of a product price decrease.

TipYou don't need to check for Web Push support, permission availability, or request it from the user using the methods available here. This method will do everything you need by itself

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("unsubscribe_trigger", "product_price_decrease", params);

NameTypeRequirementDescription
paramsObjectrequiredObject with request parameters.

Request parameters

NameTypeRequirementDescription
item_idsarrayrequiredAn array of product IDs for which the user would like to unsubscribe from the price drop notification. You can use an empty array to unsubscribe from all products.
emailstringrequiredThe current user's Email.

Examples of use

Code Block
languagejs
themeFadeToGrey
personaclick("unsubscribe_trigger", "product_price_decrease", {
    item_ids: ["100500", "146", "12"], 
    email: "john.doe@examplestore.com"
});

Code Block
languagejs
themeFadeToGrey
personaclick("unsubscribe_trigger", "product_price_decrease", {
    item_ids: [], // unsubscribe from all products
    email: "john.doe@examplestore.com"
});


Checking the "Price Drop" trigger subscription

Method Objective

The method allows checking the subscription status of the "Price Drop" trigger.

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("subscribecheck_trigger", "product_price_decrease", params, success, error);


NameTypeRequirementDescription
paramsObjectrequiredObject with request parameters.
successFunctionrequiredCallback-function, where the API response will be passed to. Response type: object.
errorFunctionoptionallyCallback-function to be called when an error occurs (any HTTP status code other than 200).

Request parameters

The current product price.
NameTypeRequirementDescription
idnumber/stringrequiredThe product ID to notify of the product price drop the user will be subscribed.
pricenumberrequireditemstring/numberrequiredProduct ID
emailstringoptionallyEmail for subscription checking
phonestringoptionallyPhone for subscription checking
loyalty_idstringoptionallyLoyalty ID for subscription checking


Note

If no email, phone, or loyalty_id is specified, only the user's current device will be checked. It won't take into account subscriptions performed on the user's other devices.

API response properties

NameTypeDescription
statusbooleanShows whether or not there is a trigger subscription for the product

Example of use

Code Block
languagejs
themeFadeToGrey
personaclick("subscribecheck_trigger", "product_price_decrease", {iditem: "100500", email: "john.doe@examplestore.com"}, function(response) {
    if (response.status) {
        console.log("Subscribed!");
    } else {
        console.log("Not subscribed!");
    }
}, function(error) {
  // if the request failed.
});


Code Block
languagejs
themeFadeToGrey
personaclick("check_trigger", "product_price: 146.55});_decrease", {item: "100500"}, function(response) {
    if (response.status) {
        console.log("Subscribed!");
    } else {
        console.log("Not subscribed!");
    }
}, function(error) {
  // if the request failed
});



Column

Page Navigation

Table of Contents
maxLevel2

classpersonaclick-fixed-position

indent0px
stylenone




Related Pages

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
sorttitle
cqllabel = "triggers"