This guide explains how to integrate Usercentrics Preference Manager (UC PM) with Mailchimp using Zapier, ensuring a seamless connection between user preferences in UC PM and Mailchimp Interest Groups.
Integration overview
The integration syncs user preferences from UC PM with Mailchimp Interest Groups (Interests) via Zapier. The user’s email address is the unique identifier in Mailchimp. When a user submits new preferences via the UC PM widget:
- for new users: a new subscriber will be added to Mailchimp with the selected Interest Groups, and double opt-in can be enabled if required
- for existing users: the subscriber’s record will be updated with the new preferences
This integration can also be extended to update additional Mailchimp fields by adding more API calls at the Zapier level.
Link between UC Preference Manager options and Mailchimp Interest Groups
Step 1: Configure UC PM Widget and Mailchimp Interest Groups
-
Create a widget in UC PM with the preference options you want to sync with Mailchimp.
Widget Structure view -
Create corresponding Interest Groups in Mailchimp:
Navigate to Audience → Manage contacts → Groups in Mailchimp to set up Interest Groups that align with your UC PM preference options.
Audience → Manage contacts → Groups
Step 2: Retrieve Mailchimp Interest Group IDs
Based on following resources:
To link UC PM preferences with Mailchimp, you need to gather the Mailchimp Interest Group IDs. Follow these steps:
- Get Mailchimp API Key from your Mailchimp account.
- Using the Mailchimp API (or tools like Postman), make the following calls:
- Get your audience list ID:
https://{your_server_prefix}.api.mailchimp.com/3.0/lists/
- Retrieve the interest categories under your list:
https://{your_server_prefix}.api.mailchimp.com/3.0/lists/{LIST_ID}/interest-categories/
- Get the interest groups under each category (these are the IDs you need):
https://{your_server_prefix}.api.mailchimp.com/3.0/lists/{LIST_ID}/interest-categories/{CATEGORY_ID}/interests/
- Get your audience list ID:
Step 3: Create a new Zap in Zapier
-
Create a new Zap and set the first trigger as Webhooks by Zapier:
Use the Catch Hook event to receive data from UC PM.
-
Skip payload element selection and copy the Webhook URL generated by Zapier. This will be used in the UC PM Admin UI.
- In the UC PM Admin UI, create a new webhook using the URL from Zapier, ensuring the payload includes user preference titles and values. Submit a test request in UC PM to trigger the webhook, and confirm Zapier catches the data.
Webhook setting details - Go back to Zapier and run the test to catch the test submission.
Step 4: Add Python code to hash the email address
Mailchimp requires a hashed version of the user’s email address for updates. To achieve this:
- Add a new step in your Zap for code by Zapier.
-
Use the following Python code to hash the email address:
Add a following code as an Action step, defining as
input
incoming data:import hashlib
email = input_data.get('input', '')
# Hash the email address using MD5 hashed_email = hashlib.md5(email.encode()).hexdigest()
# Prepare the output with the hashed email output = {'hashed_email': hashed_email} - Set the input for the Python code as the email address received from UC PM in the webhook.
Step 5: Set up Mailchimp API request in Zapier
- Add Mailchimp as the third step in your Zap using the API Request event.
- Authenticate with your Mailchimp account.
- Configure the Action step with the following details:
- HTTP method: PUT
-
URL:
https://{your_server_prefix}.api.mailchimp.com/3.0/lists/{LIST_ID}/members/{hashed_email}
- Replace
{LIST_ID}
with the Mailchimp audience ID from Step 2. - Use the hashed email output from the Python step for
{hashed_email}
.
- Replace
-
Headers: Add
Content-type: application/json
. - Add the following JSON body to update the user’s subscription and interests:
{ "email_address": "{USER_EMAIL}", "status_if_new": "subscribed", "interests": { "{ID_of_MailchimpGroup_1}": {Corresponding_PM_Option1_value}, "{ID_of_MailchimpGroup_2}": {Corresponding_PM_Option2_value}, "{ID_of_MailchimpGroup_3}": {Corresponding_PM_Option3_value} } }
- Replace
{USER_EMAIL}
with the email received from UC PM. - Replace
{ID_of_MailchimpGroup_X}
with the Mailchimp Interest Group IDs from Step 2. - Replace
{Corresponding_PM_OptionX_value}
with the matching UC PM preference values from Step 1.
Step 6: Test and validate
- Test the Zap to ensure it catches the webhook data from UC PM and correctly updates the subscriber’s interests in Mailchimp.
- Check the Mailchimp interface to verify the subscriber’s record has been updated as expected.
By following these steps, you will successfully integrate UC Preference Manager with Mailchimp via Zapier, enabling efficient synchronization of user preferences and interests.
Comments
0 comments
Please sign in to leave a comment.