Subscribe to Triggered Emails

It’s possible to subscribe to the Price drop and Back in stock specific triggered email notifications. The use-case is that a visitor would like to opt-in and subscribe to either a price drop or back in stock email notification for a specific product, by filling in their email address in a specific form constructed for the purpose.

You can use the following method to submit the visitor’s subscriber details to the triggered emails feature:

ADDWISH_PARTNER_NS.api.triggered_email.subscribe(email, type, <calback>);

Or

ADDWISH_PARTNER_NS.api.triggered_email.subscribe(email, type, url, <calback>);

email is required and must be the email address of the visitor/user who wants to subscribe to a price drop or back in stock triggered email notification.

type is required and should be either the string "price_drop" or "back_in_stock"

url is optional; this should be the url for the product which to register the trigger. If omitted, the url of the current page is used. If used, this could be: "https://webshop.com/category/fancy-product.html"

callback should be a function. It will be called with whatever status returned from the Hello Retail server:

Arguments

Argument

Type

Description

email

(required)

String

The email address of the visitor/user who wants to subscribe to a price drop or back in stock triggered email notification.

type

(required)

String

Should be either the string "price_drop" or "back_in_stock".

url

(optional)

String

This should be the URL for the product which to register the trigger. If omitted, the url of the current page is used. If used, this could be: "https://webshop.com/category/fancy-product.html"

callback

method

The method which will be invoked after the status is returned from the Hello Retail server. The callback will return the status as shown below.

Here is the list of status types that the callback can return:

Status

Description

ok:

The email is successfully registered. We will send an email when the selected event occurs for the specified product. This code is also returned if the same email was already registered for the same event on the same product. We will only send one email when the event occurs, even if the email is registered multiple times.

invalid_email:

The entered email is invalid.

invalid_type:

The type parameter did not have an accepted value.

missing_product:

We couldn’t find a product with the url you specified. (Hint: Check it using our product lookup in the dashboard)

not_enabled:

You haven’t enabled the triggered email feature, or you haven’t enabled the trigger corresponding to the type.

unknown_error:

An unexpected error occurred.

Example
Example

<form id="price_drop_form">
<label>
Type your email address to get a notification when this product drops in price:
<input type="email" id="price_drop_email">
</label>
<button id="subscribe">Notify me</button>
</form>
<span id="status"></span>
<script>
$("#price_drop_form").on("submit", function(e) {
ADDWISH_PARTNER_NS.api.triggered_email.subscribe($("#price_drop_email").val(), "price_drop", function(status) {
if (status === "ok") {
$("#price_drop_form").hide();
$("#status").text("Thank you! We'll let you know when this product drops in price.");
} else {
$("#status").text("Sorry, an error occured - " + status);
}
});
// Prevent the form from actually submitting:
e.preventDefault();
return false;
});
</script>