Double opt-in settings in Boldem

Michal Michal Krejčí
15. September 2023

The so-called double opt-in, or double confirmation of consent, is the traditional way to request a recipient’s consent to receive email messages immediately after subscribing and to confirm that the recipient’s email address exists and works.

Double opt-in is essentially protection against unsolicited mail and involves verifying the email addresses you collect via, for example, a website or form. It’s used, for example, for newsletter login, training login, account setup, orders, and similar.

Prerequisites

Double opt-in is most often used when collecting email addresses via subscription forms or the Boldem API. The prerequisites for successful use with a subscription form are as follows:

  • Transactional template.
  • Mailing list configured for double opt‑in.
  • A created and enabled subscription form with at least one field for collecting email addresses.
  • Verified domain.
  • A website connected to Boldem where you can display the subscription form.
  • 3 URLs, i.e., web pages (so-called landing pages) on the integrated website
    • The page where you display the subscription form to the user.
    • The page shown to the user after successfully filling out and dispatching the form.
    • The page to which you redirect the user after they click the subscription confirmation link in the confirmation email.

Creating a transactional template

First, you need to create a transactional template that will be sent to the recipient after the form is submitted. It should include information explaining why the recipient must confirm their subscription to your emails and what the content covers.

  1. Click on Templates and create a new smart template. You can use a sample template or a blank one.
  2. Add the appropriate text and at least one button to the template.
  3. Click inside the button and in the left Button link field enter the string {{subscribeUrl}}. You can also use a text block and paste this string as a URL, but it’s more practical for users to click a larger element, such as a button.
  4. Click Back twice, and on the Information tab, enter the template name and Subject.
  5. Turn on the Template for transactional emails (automation and API) toggle switch.
  6. Enter the sender’s email (ideally the sender’s email should be on the same domain as your domain router, i.e., your verified domain).
  7. Save the template.

Creating a condition to exclude existing recipients

This optional step lets the template check whether a recipient is already in your database (more precisely, your mailing list) and show them personalized content accordingly.

Using conditionals in Scriban

For this purpose you can use Scriban code in templates to apply conditions that dynamically generate template content based on recipient data, such as whether the recipient is in a particular mailing list. When creating these conditions, use the if/else/end keywords to determine whether a specific block of code should be executed based on the condition.

To check whether a recipient is in any mailing list, use the following code:

{{ if subscribeContact.existsInAnyMailingList }}
  You're already on our mailing list!
{{ else }}
  Confirm your email address.
{{ end }}

This code checks whether the recipient is part of any mailing list in your account. If so, it displays the text “We already know each other!”, otherwise it displays the text “Confirm your email address.”

In practice, you’ll use this feature if you want to offer a discount or other benefit only to recipients who sign up for your newsletter for the first time. In that case, of course, adjust the texts to suit your needs.

Also keep in mind that when doing a global check with existsInAnyMailingList — i.e., checking whether a recipient is part of any mailing list — the recipient must always confirm their email address if they want to be added to a new list. Adjust the texts in the template accordingly.

You can check if a recipient is in a specific mailing list with the following code:

{{ if subscribeContact.existsInMailingList }}
  We already have you in our database.
{{ else }}
  We need to verify it's really you.
{{ end }}

This code checks whether the recipient is part of the specific mailing list you’re working with in the form. It then displays the appropriate message based on the result.

Negate conditions

In some cases you may want to use negation. In that case, the code will run if the condition is not met. To do this, use the ! operator before calling the method.

Negation for any mailing list:

{{ if !subscribeContact.existsInAnyMailingList }} Confirm your email address. {{ else }} We already know each other! {{ end }}

This code will display the text “Confirm your email address.” if the recipient is not part of any mailing list.

Negation for a specific mailing list:

{{ if !subscribeContact.existsInMailingList }}
  We need to know it's really you.
{{ else }}
  You're already in our database.
{{ end }}

This code displays the text “We need to know that it’s really you.” if the recipient is not part of a specific mailing list.

You can find a practical example of using the template in the chapters below.

Edit Template Subject

Open the transactional template for editing and paste the code below into the Subject field, then change the text as desired to match your goal. Use the condition when, for example, you want to offer promo codes only to recipients who newly sign up to receive messages, not to existing recipients.

Please note that when performing a global check using existsInAnyMailingList, i.e., checking whether a recipient is part of any mailing list, the recipient must always confirm their email address if they want to be added to a new list. Adjust the texts in the template accordingly.

Subject

Code to check whether the recipient is part of any mailing list in your Boldem account:

{{ if subscribeContact.existsInAnyMailingList}}You're already on our list!{{ else }}Confirm your email address.{{ end }}

Code to determine whether the recipient is part of a specific mailing list in your Boldem account — the list you’re working with in the form:

{{ if subscribeContact.existsInMailingList}}You're already subscribed!{{ else }}Confirm your email address.{{ end }}

In both cases, the template subject will display the text We already know you! if the user’s email address is on a mailing list (either on any of them or on a specific one). If the email address is unknown, the text Confirm your email address will be displayed.

Edit template body

Open the transactional template for editing and insert the code below into the block where you want different content to appear. Adjust the text and formatting to match the contexts of your template:+

template

Code to check whether the recipient is part of any mailing list in your Boldem account:

{{ if subscribeContact.existsInAnyMailingList }}We already have your email verified in our database, but if you'd like to receive updates from this newsletter as well, please confirm your subscription using the button below.

Go to the Boldem website
{{ else }}Thank you {{vokativ subscribeContact.name}}.
Please confirm your email address and be the first to hear about all webinars and updates.{{ end }}

Code to determine whether the recipient is part of a specific mailing list in your Boldem account — the list you’re working with in the form:

{{ if subscribeContact.existsInMailingList}}You're already in our database.{{ else }} We need to know it's really you.{{ end }}

{{ if subscribeContact.existsInMailingList }}Your email is already verified in our database, so we don't need confirmation.

Go to the Boldem website
{{ else }}Thank you {{vokativ subscribeContact.name}}. 
Please confirm your email address and be the first to know about all webinars and news.{{ end }}

If a user’s email address is found in the mailing list, the template will display information that the recipient already exists in your database, or other details you configured, depending on whether this is a global check or a check of a specific mailing list. If the email address is unknown, a message prompting email address confirmation will be displayed.

Create or configure a mailing list

  1. Go to Mailing Lists and select an existing mailing list to store the collected recipients and send them confirmation requests. You can also create a new mailing list.
  2. From the menu on the right (three vertical dots), select Edit list.
  3. Click on Use double opt-in.
  4. Select the transactional template from the drop-down menu.
  5. In the Redirect to URL field, enter the website URL to which you will redirect users after they submit the form on the website.
  6. In the Redirect to URL after confirmation field, enter the URL of the web page where users will be sent after they click the button or link in the email.
  7. Select the domain router and click Save.

Creating a subscription form

  1. Click on Subscription forms and select Create new form.
  2. Fill in the details, select the mailing list you created above, and click Create form.
  3. In the editor, click Insert content and select Text field.
  4. Click inside the text field. Edit Block will appear on the left.
  5. From the drop-down menu Custom field to save the data to, select Email.
  6. Edit the title and description.
  7. Add other content, images, or text as needed, or modify colors, background, and the like.
  8. Go back, or click an empty spot in the form to insert the button.
  9. Click Allow at the top of the page.
  10. Save the form.
    Note: Don’t be confused if the form’s background shows the sending domain’s page instead of the website where you plan to display the form. You can find your website’s address in Settings/Websites.

By default the form is shown to each visitor only once and immediately after any page finishes loading on the integrated website. On the Settings tab, under Window Configuration, you can customize the form’s behavior and display. Most often you’ll need to adjust Display restrictions on specific pages. To show the form only on certain pages, enter the individual URL paths into this field without the domain, with slashes at both ends; e.g. /contact/ or /my-blog-post/. Press Enter after each path.

Displaying the form on the website and testing the functionality

  1. Go to Settings and open Websites.
  2. Click the address of the website for which you set up the form.
  3. If your website is properly integrated with Bold, the form will appear on it based on the rules you set in the form’s properties.
  4. Enter a valid email address in the form and submit it.
  5. Check that you were redirected to the first URL you entered in the Double opt-in settings.
  6. Go to the inbox for the email address you entered in the form. You should see a confirmation email there (the transactional template you used above).
  7. Click the link in the email.
  8. Verify that you were redirected to the second URL you entered in the mailing list settings.
  9. Go back to the Boldem app and open the mailing list you selected when creating the form.
  10. Check whether it contains the email address you tested.

By default, the form on the website is shown to each user only once. If you need the form to behave differently or want to test it multiple times, you can adjust the settings. In that case, follow these steps:

  1. Return to the form editor, go to the Settings tab, and select Window Configuration.
  2. Toggle the Show only once field to the off position and click Done/Save.
  3. Return to the website with the form and refresh the page.
  4. The form will reappear.

After testing, don’t forget to change the settings back to how you want the form to appear to website visitors.

Go back to the form settings, open the Settings/Window Configuration tab, switch the Show only once option to On, and click Done/Save.