docs
  1. Checkout Guide
  2. How Tos
  3. How To Let Users Sign Up To The Newsletter During Checkout

How to let users sign up to the newsletter during Checkout

This feature can be used to enable your customers to subscribe to your newsletter by selecting a checkbox during the checkout process.

How it works

After enabling the newsletter signup feature within the Checkout Frontend, your customers are able to select a checkbox to subscribe to your newsletter. When a customer selects the checkbox and proceeds to the next step, the newsletter-subscribed webhook event is emitted by checkout.

In order to forward such subscriptions to your newsletter provider, you must provide an application that can receive newsletter-subscribed webhook events.

\

Subscribing to Newsletter Subscription events

To subscribe to newsletter-subscribed webhook events (we suggest to use the capabilities of the Admin API to subscribe to webhooks.

Use the following payload to subscribe your service to newsletter-subscribed webhooks via Admin API.
POST

{
    "event": "newsletter-subscribed",
    "version": 1,
    "url": "https://your-newsletter-endpoint.tld"
}

Alternatively, you may also setup your webhook subscriptions via the SCAYLE Panel.

Handling Newsletter Subscriptions

When customers subscribe to newsletters during checkout, checkout will emit a newsletter-subscribed webhook event. This is a POST request to the previously configured endpoint.

Request

The request contains data about the customer as well as metadata about the date, shop, and locale for which the newsletter subscription occurred.

See the full specification for the newsletter-subscribed webhook event.

Response

To acknowledge the webhook request, your endpoint must respond with http status code 200 and an empty response body. If your endpoint does not respond with http status code 200, the webhook request will be retried.

Configuration

To show the newsletter subscription checkbox in the checkout frontend, you need to enable it in the checkout configuration as dynamic fields.

A newsletter sign up box can be enabled as follows.

{
  "name": "newsletterSignUp",
    "i18nKeys": {
      "label": "auth.newsletterSignUp"
    }
}

Best Practices

Keep your service stateless

We suggest to keep your newsletter subscription service stateless, following a simple ‘Gateway’ pattern that forwards newsletter subscriptions from SCAYLE to your preferred newsletter provider. By keeping your service stateless, you do not need to persist personal data.

Keep in mind that you can make use of SCAYLE’s built-in retry mechanism - in case a newsletter subscription webhook runs into an error, you can place it back in the queue by responding with a code other than 200.

Authentication & Authorization

To protect your newsletter service and your newsletter provider from unauthenticated access, you may protect the API endpoint using Basic Authentication.