Skip to content

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.

Subscribe using the SDK

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

hrq = window.hrq || [];
hrq.push([
    "triggeredEmailSubscribe",
    email,
    type,
    <callback>
]);

or if you want to include the url of a product:

hrq = window.hrq || [];
hrq.push([
    "triggeredEmailSubscribe",
    email,
    type,
    url,
    <callback>
]);

Here's the break down:

Field Type Description
email String (required) The email address of the visitor/user who wants to subscribe to a Price drop or Back in stock triggered email notification.
type String (required) Should be either the string "price_drop" or "back_in_stock".
url 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 function The method which will be invoked after the status is returned from the Hello Retail server. The callback will return the status as shown on the next tab.

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

Status Description
email subscribed: 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.
email is invalid: The entered email is invalid.
type is invalid: The type parameter did not have an accepted value.
url is missing: The url is missing
No product with given url found: We couldn't find a product with the url you specified. (Hint: Check it using our product lookup in the dashboard)
websiteUuid does not match the websiteUuid of the product: The provided websiteUuid and acutal website of the product does not match.
Triggered Email Feature 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.
<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) {
        hrq = window.hrq || [];
        hrq.push([
            "triggeredEmailSubscribe",
            $("#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>

Triggered emails using the REST API

The Hello Retail SDK uses a REST API endpoint to subscribe to triggered emails. This API can also be used directly.

Request

The endpoint is available at https://core.helloretail.com/serve/triggers/subscribe. You can use it by sending a HTTP POST request with a JSON body. The content type must be application/json or text/plain 1.

Example of the structure the JSON body must have:

{
    "websiteUuid": "{website uuid}",
    "email": "customer@example.com",
    "url": "https://webshop.com/category/fancy-product.html",
    "type": "price_drop",
}

The information about each part of the JSON body are already provided above, except websiteUuid

Property Type Description
websiteUuid String The id identifying the website in Hello Retail. This can be found on my.helloretail.com

Response

The response will indicate if the subscribe to triggered emails succeeded. A success response will have the 200 response code. The body of the response will look like this:

{
    "success": true,
    "message": "email subscribed"
}

If the process fails because of invalid input the response will have the 400 response code. An example could be not supplying the type or supplying a type that does not match to Price drop and Back in stock. This will result in the following response:

{
    "success": false,
    "message": "type is invalid"
}

If the subscribe to triggered emails fails for other reasons it will fail with the 500 response code. If you experience this please contact Hello Retail support.


  1. The reason for supporting text/plain is to allow requests to this endpoint, made from the browser, to be categorized as simple thereby avoiding CORS preflight requests. You can read more here https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests