Newsletter agreements

You can enable newsletter agreements by using an HTML form, calling the SDK, or using the API.

HTML form

Prerequisites

Use the data-synerise="newsletterAgreement" and data-synerise-value="enabled" attributes (both attributes are required) on an input element in the form.

Option 1: Invisible input element; customer only provides the email

<form action="" method="post" data-synerise="newsletter">
    <input type="text" name="email" data-synerise="email" placeholder="Email" value="john.doe@synerise.com" />
    <input type="submit" value="Subscribe">
    <input type="hidden" data-synerise="newsletterAgreement" data-synerise-value="enabled" id="newsletterAgreement">
    <!-- Additional fields --> 
</form>

Option 2: A visible checkbox

Important: The value and additional attributes of the checkbox are sent only if the checkbox is selected.
<form action="" method="post" data-synerise="newsletter">
    <input type="text" name="email" data-synerise="email" placeholder="Email" value="john.doe@synerise.com" />
    <input type="checkbox" data-synerise="newsletterAgreement" data-synerise-value="enabled" id="newsletterAgreement" checked>
    <label for="newsletterAgreement">I want to receive the newsletter</label>
    <input type="submit" value="Subscribe">
    <!-- Additional fields --> 
</form>

This information is processed in the following way:

  1. A form.submit event with the data is saved to the customer’s account.
  2. The customer’s profile is updated with the 'newsletter_agreement_enabled': 'enabled' attribute.
  3. An event with details of the profile update is created and triggers the workflow that collects newsletter agreements.
  4. One of the following happens:
    • If single opt-in is used, the agreement is enabled. Depending on the workflow configuration, the customer may receive an email with a notification.
    • If double opt-in is used, the customer receives an email and must click the link in that email to confirm the subscription.

JavaScript SDK

Prerequisites

Enabling a newsletter agreement

To enable a customer’s newsletter agreement, use the following SDK method:

SR.event.sendFormData('newsletter-agreement', {
    email: 'john.doe@synerise.com',
    newsletterAgreement: 'enabled' //translates to "newsletter_agreement_enabled: 'enabled'" for the backend
})

This information is processed in the following way:

  1. A form.submit event with the data is saved to the customer’s account.
  2. The customer’s profile is updated with the 'newsletter_agreement_enabled': 'enabled' attribute.
  3. An event with details of the profile update is created and triggers the workflow that collects newsletter agreements.
  4. One of the following happens:
    • If single opt-in is used, the agreement is enabled. Depending on the workflow configuration, the customer may receive an email with a notification.
    • If double opt-in is used, the customer receives an email and must click the link in that email to confirm the subscription.

Disabling a newsletter agreement

To disable a customer’s newsletter agreement, use the following SDK method:

SR.event.sendFormData('newsletter-agreement', {
    email: 'john.doe@synerise.com',
    newsletterAgreement: 'disabled'
})

The agreement is disabled immediately and a form.submit event with the data is saved to the customer’s account.

API

Enabling a newsletter agreement

When using the API, you can use single/double opt-in or enable the agreement immediately.

With single/double opt-in

Ensure that a workflow for collecting newsletter agreements is running.

Send a create/update API call with the "newsletter_agreement_enabled": "enabled" attribute.
API reference is available here.

curl --location --request POST 'api.synerise.com/v4/clients/batch' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Api-Version: 4.4' \
--header 'Authorization: Bearer eyJ...G2DI' \
--data-raw '[
   {
      "email": "john.doe@synerise.com",
      "attributes": {
          "newsletter_agreement_enabled": "enabled"
      }
   }
]'

This information is processed in the following way:

  1. The customer’s profile is updated with the 'newsletter_agreement_enabled': 'enabled' attribute.
  2. An event with details of the profile update is created and triggers the workflow that collects newsletter agreements.
  3. One of the following happens:
    • If single opt-in is used, the agreement is enabled. Depending on the workflow configuration, the customer may receive an email with a notification.
    • If double opt-in is used, the customer receives an email and must click the link in that email to confirm the subscription.

Immediately

You can also immediately enable an agreement over the API, without asking for confirmation or notifying the customer.

Send a create/update API call with the agreements.email param set to true. API reference is available here.

curl --location --request POST 'api.synerise.com/v4/clients/batch' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Api-Version: 4.4' \
--header 'Authorization: Bearer eyJ...G2DI' \
--data-raw '[
   {
      "email": "john.doe@synerise.com",
      "agreements": {
         "email": true
         }
      }
   }
]'

Disabling a newsletter agreement

Send a create/update API call with the agreements.email param set to false. API reference is available here.

curl --location --request POST 'api.synerise.com/v4/clients/batch' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Api-Version: 4.4' \
--header 'Authorization: Bearer eyJ...G2DI' \
--data-raw '[
   {
      "email": "john.doe@synerise.com",
      "agreements": {
         "email": false
         }
      }
   }
]'

The agreement is disabled immediately.

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker