Contents

Newsletter

The Newsletter sign-up block puts a heading and a text beside a form from Forms → Forms that has an email field. Its submissions are stored like every form's, under Forms → Form Submissions, whether or not a newsletter service is set up.

Pass sign-ups on to Mailchimp #

  1. Set MAILCHIMP_API_KEY and MAILCHIMP_AUDIENCE_ID. The key is under Account → Extras → API keys in Mailchimp, the audience id under Audience → Settings → Audience name and defaults.
  2. Restart the site. A tick box, Add sign-ups to the newsletter list, appears in the sidebar of every form. Without both variables it stays hidden and nothing is sent anywhere.
  3. Tick it on the sign-up form. Only ticked forms are sent; a contact form never is.

A public demo (DEMO_MODE) passes nothing on, even with both variables set: see Live demo.

Each new submission of a ticked form is then added to the audience with:

  • the answer to the form's email field;
  • a name, from fields named firstName and lastName (or name);
  • the language the visitor signed up in.
  • An existing member's status is never changed, so someone who unsubscribed is not subscribed again.
  • Double opt-in: set MAILCHIMP_DOUBLE_OPT_IN=true to have Mailchimp ask new subscribers to confirm by email. Otherwise they are subscribed at once.
  • Terms: add a required checkbox to the form if visitors must agree to something first.

When Mailchimp fails #

The visitor's submission is kept, and the error is logged without the address. Nothing is retried: the submission is the record to follow up from.

Another service #

Sign-ups go through one small interface in src/utilities/newsletter. To use another service, add a file beside mailchimp.ts that implements NewsletterAdapter, and choose it by its own environment variables in newsletterAdapter() in index.ts. Add the variables to .env.example and run pnpm docs:env.

These guides ship with Tolk Starter 0.6.0: buyers get the same pages in their repository, next to the code they describe.