We’ve migrated our documentation to a new site, which means some URLs have changed. If you hit a broken link, submit a support ticket.
Subscriptions

How to allow users to subscribe to multiple ESP mailing lists from an offer template?

Subscribe users to multiple ESP mailing lists using the JavaScript below:

JavaScript
var email   = ::EMAIL::;      
  var API_URL = ::API_URL::;
  var SITE_ID = ::SITE_ID::;
  var MAILING_LISTS = [ ::MAILING_LISTS:: ];
  var body = {email: email, sqids: MAILING_LISTS};
  var xhr = new XMLHttpRequest();
  xhr.open('POST', API_URL + '/tracker/lucid/sub/' + SITE_ID, true);
  xhr.setRequestHeader('Content-type', 'application/json');
  xhr.send(JSON.stringify(body));

Fill in the following values:

::EMAIL:: - the user's email
::API_URL:: - the API base URL for your ESP environment, for example //api-esp.piano.io or //sandbox-api-esp.piano.io.
::SITE_ID:: - your Site ID in ESP
::MAILING_LISTS:: - an array of Mailing list IDs

Add this script to your Offer template using the <div custom-script> method. Use it to create a template where subscribers select and join multiple newsletters. You can deploy that offer template in any Composer Experience.

Alternatively, create a built-in ESP opt-in form and configure groups of mailing lists for your audience. Then use the Show newsletter signup action card in Composer to display the form. More information is available here.


Last updated: