
You can enable newsletter agreements by using an HTML form or calling the SDK. For the API method, see [Managing newsletter agreements with API](/developers/api/clients/newsletter-agreements).


<div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

Custom agreements, such as agreement to receive alcohol commercials, are saved as custom profile attributes (for example, `"agreeToAlcoholAds": true`). They can be managed like other custom attributes.<br>
If you want to collect custom attributes for use as agreements with an HTML form or JS SDK methods, see [Tracking form data](/developers/web/tracking-form-data).

</div></div></div>


## Prerequisites
These prerequisites apply to HTML forms and SDK methods.

- Ensure that a [workflow for collecting newsletter agreements](/docs/settings/configuration/newsletter-sign-up) is running.  
- If you're not authenticating the form with [JWT](/developers/web/jwt-auth), ensure that the `form.submit` event is allowed to:
    - be sent without JWT.
    - update profile information without JWT.  
    See [Event authentication settings](/docs/assets/events/event-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.


<details class="accordion"><summary>Option 1: Invisible input element; customer only provides the email</summary><div class="accordion-content"><pre><code class="language-html">&lt;form action="" method="post" data-synerise="newsletter"&gt; &lt;input type="text" name="email" data-synerise="email" placeholder="Email" value="john.doe@synerise.com" /&gt; &lt;input type="submit" value="Subscribe"&gt; &lt;input type="hidden" data-synerise="newsletterAgreement" data-synerise-value="enabled" id="newsletterAgreement"&gt; &lt;!-- Additional fields --&gt; &lt;/form&gt;</code></pre></div></details>



<details class="accordion"><summary>Option 2: A visible checkbox</summary><div class="accordion-content"><div class="admonition admonition-important"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content"> <p>The value and additional attributes of the checkbox are sent only if the checkbox is selected.</p> </div></div></div> <pre><code class="language-html">&lt;form action="" method="post" data-synerise="newsletter"&gt; &lt;input type="text" name="email" data-synerise="email" placeholder="Email" value="john.doe@synerise.com" /&gt; &lt;input type="checkbox" data-synerise="newsletterAgreement" data-synerise-value="enabled" id="newsletterAgreement" checked&gt; &lt;label for="newsletterAgreement"&gt;I want to receive the newsletter&lt;/label&gt; &lt;input type="submit" value="Subscribe"&gt; &lt;!-- Additional fields --&gt; &lt;/form&gt;</code></pre></div></details>


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](/docs/settings/configuration/newsletter-sign-up). 
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

### 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:

<div class="content-tabs" data-tab-group="tabgrp-1238">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-1238-0" data-tab-group="tabgrp-1238" data-tab-active="true">Email</button><button class="tab-button" data-tab-id="tabgrp-1238-1" data-tab-group="tabgrp-1238">Custom ID</button></div>

<div class="tab-panel" data-tab-id="tabgrp-1238-0" data-tab-group="tabgrp-1238" data-tab-active="true">

Email can be used as an identifier only when [non-unique emails](/docs/settings/configuration/non-unique-emails) are disabled.

<pre><code class="language-js">SR.event.sendFormData('newsletter-agreement', {
    email: 'john.doe@synerise.com',
    newsletterAgreement: 'enabled' //translates to "newsletter_agreement_enabled: 'enabled'" for the backend
})</code></pre>

</div>

<div class="tab-panel" data-tab-id="tabgrp-1238-1" data-tab-group="tabgrp-1238">

Custom ID can be used as an identifier only when [non-unique emails](/docs/settings/configuration/non-unique-emails) are enabled. 

<pre><code class="language-js">SR.event.sendFormData('newsletter-agreement', {
    custom_identify: 'somecustomid',
    newsletterAgreement: 'enabled' //translates to "newsletter_agreement_enabled: 'enabled'" for the backend
})</code></pre>

</div>
</div>


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](/docs/settings/configuration/newsletter-sign-up). 
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 `SR.event.sendFormData()` method. As the profile identifier, you can use the email address or the custom ID:

<div class="content-tabs" data-tab-group="tabgrp-1239">
<div class="tab-buttons"><button class="tab-button" data-tab-id="tabgrp-1239-0" data-tab-group="tabgrp-1239" data-tab-active="true">Email</button><button class="tab-button" data-tab-id="tabgrp-1239-1" data-tab-group="tabgrp-1239">Custom ID</button></div>

<div class="tab-panel" data-tab-id="tabgrp-1239-0" data-tab-group="tabgrp-1239" data-tab-active="true">

Email can be used as an identifier only when [non-unique emails](/docs/settings/configuration/non-unique-emails) are disabled.

<pre><code class="language-js">SR.event.sendFormData('newsletter-agreement', {
    email: 'john.doe@synerise.com',
    newsletterAgreement: 'disabled'
})</code></pre>

</div>

<div class="tab-panel" data-tab-id="tabgrp-1239-1" data-tab-group="tabgrp-1239">

Custom ID can be used as an identifier only when [non-unique emails](/docs/settings/configuration/non-unique-emails) are enabled. 

<pre><code class="language-js">SR.event.sendFormData('newsletter-agreement', {
    custom_identify: 'somecustomid',
    newsletterAgreement: 'disabled'
})</code></pre>

</div>
</div>


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