Newsletter agreements
You can enable newsletter agreements by using an HTML form or calling the SDK. For the API method, see Managing newsletter agreements with API.
"agreeToAlcoholAds": true
). They can be managed like other custom attributes.If you want to collect custom attributes for use as agreements with an HTML form or JS SDK methods, see Tracking form data.
Prerequisites
These prerequisites apply to HTML forms and SDK methods.
- Ensure that a workflow for collecting newsletter agreements is running.
- If you’re not authenticating the form with JWT, ensure that the
form.submit
event is allowed to:- be sent without JWT.
- update profile information without JWT.
See Event authentication settings.
HTML form
Use the data-synerise="newsletterAgreement"
and data-synerise-value="enabled"
attributes (both attributes are required) on an input
element in the form.
<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>
<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:
- A
form.submit
event with the data is saved to the customer’s account. - The customer’s profile is updated with the
'newsletter_agreement_enabled': 'enabled'
attribute. - An event with details of the profile update is created and triggers the workflow that collects newsletter agreements.
- 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
Enabling a newsletter agreement
To enable a customer’s newsletter agreement, use the SR.event.sendFormData()
method. As the profile identifier, you can use the email or the custom ID:
Email can be used as an identifier only when non-unique emails are disabled.
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:
- A
form.submit
event with the data is saved to the customer’s account. - The customer’s profile is updated with the
'newsletter_agreement_enabled': 'enabled'
attribute. - An event with details of the profile update is created and triggers the workflow that collects newsletter agreements.
- 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 SR.event.sendFormData()
method. As the profile identifier, you can use the email address or the custom ID:
Email can be used as an identifier only when non-unique emails are disabled.
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.