Skip to main content

How to Check if Multiple Profiles Share an Email Address

If you’ve integrated Customer.io with multiple data sources, you might run into the case where multiple profiles share one email address. While there is no way to merge or alias profiles in Customer.io – this article will show you how to:

  1. Automatically check if another profile exists with the same email address.
  2. Mark profiles with shared emailed addresses as either primary or secondary.

What this solves

As people go through your workflows or receive your broadcast, Customer.io sees every profile as an individual. If an email address is shared across multiple profiles, that means the same email address could receive duplicates of the same campaign or email. Using this method, you can mark one of these shared profiles as primary with an attribute. You can then use that attribute to make sure only that primary profile is messaged.

How to do it

Step 1: Create a new condition triggered campaign

Start by creating a new condition triggered campaign in Customer.io. The segment you create should be broad enough, so it captures everyone who has an email address. This way, you can be sure you’ve checked every email address for duplicates.

Step 2: Add a Webhook Action

The only step needed in this campaign is one webhook action that hits the Customer.io API. Set the request type to GET and the request URL to https://api.customer.io/v1/customers?email={{customer.email | url_encode}} or, if you’re on our EU servers, to https://api-eu.customer.io/v1/customers?email={{customer.email | url_encode}}

Next, you’ll need to add one header called Authorization with a value of Bearer YOUR-APP-API-KEY-HERE. You can find (or create) your App API key in Account Settings > API Credentials > App API Keys.

Step 3: Use the Webhook Response to Add Primary Attribute

When you successfully set up the Customer.io Beta API as described above, it will return the list of all profiles that match that email address. You can then use Liquid logic in the response tab to determine if there is more than one match. From there, you can determine which profile should be marked primary. Here’s what that would look like:

{% if response.results.size > 1%}false{% else %}true{% endif %}

Again, if the Beta API returns more than one result that means the email exists in multiple profiles. For this example, we’ll assume that any new profile in the workspace, with a shared email address, will not be primary. Therefore we set this new attribute to false.

Depending on your specific use case, you may want to add additional logic to determine which of the profiles is the primary lead. For example, if you had a personal attribute source, you could pick a certain source as the primary and all others as secondary:

{% if response.results.size > 1 and customer.source == 'mobile-app'%}true{% elsif response.results.size > 1 and customer.source != 'mobile-app'%}false{% endif %}

These webhook actions need to be customized for your unique workspace requirements, but with Liquid and Webhook Responses you can build the exact solution you need.