This document will guide you through the basics of setting up double opt-in functionality for your users. If you already have your integration set up, we’ll be creating a new attribute for your users that will keep track of whether or not they’ve confirmed their desire to receive communication from you!
- A way to add new users to your Customer.io account (in this recipe, we are adding new users via a terminal window using cURL)
- Your site ID and API key
First and foremost, we’ll need an attribute for each person which tracks whether or not they’ve been through the double-opt in process, and what they’ve chosen.
When adding people to Customer.io, create an attribute for all of them which will indicate their confirmation status, and set it to
false by default. In this example, we’ll name that attribute
has_confirmed_subscription and set it to
You’ll want to make sure that you send the attribute every time you add a new person to your account, like this:
curl -i https://track.customer.io/api/v1/customers/:id \ -X PUT \ -u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \ -d firstname.lastname@example.org \ -d created_at=1361205308 \ -d first_name=Bob \ -d has_confirmed_subscription=false
Using the attribute above, create a “Hasn’t confirmed subscription” segment in your account, for cases where this attribute is set to
At the same time, create another segment in your account of people whose
has_confirmed_subscription value is equal to
true. These are the people who have created a subscription. We’ll use this segment later:
Create a condition-triggered campaign that is triggered by the “Hasn’t confirmed subscription” segment. Newly-added people who haven’t confirmed their subscription (yet) will enter this segment, and this campaign will send a message asking them to confirm!
Here’s what the trigger looks like:
To the workflow, drag and drop whatever confirmation message you want to send; in our case, it will be an email that sends the user to a specific page where they can finish the opt-in process:
And here’s the email we want to send:
In our case, the button will send the user to a page which allows them to explicitly opt in.
There are a variety of ways to update this attribute. In our case, when a user clicks the button in the email above and views the Confirmation page, we can send an API call to update that user’s
has_confirmed_subscription value to
It depends on what your business requires to confirm the user really wants to hear from you. This might just mean a page view, or it might mean that they interact with another form or button.
When the user completes that action, send us an API call to update the attribute. Here’s an example (we’re updating the profile via a terminal window using cURL) which includes the customer’s
id (required), email address, and the attribute change
curl -i https://track.customer.io/api/v1/customers/:id \ -X PUT \ -u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \ -d email@example.com \ -d has_confirmed_subscription=true
Remember the “Has confirmed subscription” segment we created above? Now, any time you want to ensure that your messages only go to people who have double opted-in, you can use that segment as a filter in your campaigns.
Here’s an example where we want to send a new feature announcement to our power users, but only those who have gone through the double opt-in process:
This will ensure that the message goes out to only those who have confirmed. For new customers, this means that you can send them straight to this page as part of your initial communication with them.
If you have people in Customer.io that you need to ask for confirmation, they may not have this attribute created or set. In this case, you can send them a single newsletter which asks them to confirm their subscription. In our example, the newsletter Recipients would be those for whom the attribute does not exist:
It could have the same email content as the above confirmation campaign:
And then, when they opt in, set the
has_confirmed_subscription attribute to