Using hidden field email in mailchimp integration | Community
Skip to main content
Answered

Using hidden field email in mailchimp integration


Hello, 

I have a Typeform survey and instead of asking the users for their emails, I use a hidden field (Since I already know their emails.)

I would like to use that hidden field when integrating with Mailchimp. In its current form, the connect integration does not allow that. It has to be an actual question of the survey. As shown below:


Is there a way for me to use the hidden field instead of an actual survey question without resorting to using third parties?

Thanks in advance!

Best answer by levasa

Hello, 

 

So, I wrote a lambda function, hooked it up through an API gateway endpoint.
Typeform sends the data over and it’s quite simple to parse and use. Below i a simplified version of my script. When calling Mailchimp, you can map responses to any fields you’d like too.

(handler here is a custom utility class I have to handle lambda errors, no need to worry about it for this.)
 

const mailchimp = require('@mailchimp/mailchimp_marketing');

mailchimp.setConfig({
  apiKey: 'myKey',
  server: 'myServer',
});

const audienceId = 'myAudience';

export const main = handler(async (event) => {
  const surveyData = JSON.parse(event.body);

  const subscribingUser = {
    email: surveyData.form_response.hidden.email,
  };

  try {
    const response = await mailchimp.lists.addListMember(audienceId, {
      email_address: subscribingUser.email,
      status: 'subscribed',
    });
    console.log(
      `Successfully added contact as an audience member. The contact's id is ${response.id}.`
    );
  } catch (error) {
    console.error(error);
  }
});

Enjoy!

View original

8 replies

  • Author
  • Explorer
  • 2 replies
  • April 28, 2022

I managed to make it work using a webhook running on AWS and the mailchimp sdk. But it seems it could be way simpler.


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14971 replies
  • April 28, 2022

Hi @levasa Glad to hear you were able to make it work through webhooks! Our native integration requires an email question on the form, so the workaround you have currently sounds like a great one! You could also use Zapier to pass the data to your Mailchimp account. 


Gabi Amaral
Ex–Typefomer
Forum|alt.badge.img+5
  • Ex–Typefomer
  • 1777 replies
  • April 29, 2022

Can you give us more details on how you made this work, @levasa? I'm interested on this solution!


  • Author
  • Explorer
  • 2 replies
  • Answer
  • April 29, 2022

Hello, 

 

So, I wrote a lambda function, hooked it up through an API gateway endpoint.
Typeform sends the data over and it’s quite simple to parse and use. Below i a simplified version of my script. When calling Mailchimp, you can map responses to any fields you’d like too.

(handler here is a custom utility class I have to handle lambda errors, no need to worry about it for this.)
 

const mailchimp = require('@mailchimp/mailchimp_marketing');

mailchimp.setConfig({
  apiKey: 'myKey',
  server: 'myServer',
});

const audienceId = 'myAudience';

export const main = handler(async (event) => {
  const surveyData = JSON.parse(event.body);

  const subscribingUser = {
    email: surveyData.form_response.hidden.email,
  };

  try {
    const response = await mailchimp.lists.addListMember(audienceId, {
      email_address: subscribingUser.email,
      status: 'subscribed',
    });
    console.log(
      `Successfully added contact as an audience member. The contact's id is ${response.id}.`
    );
  } catch (error) {
    console.error(error);
  }
});

Enjoy!


picsoung
Typeform
Forum|alt.badge.img+5
  • Developer Advocate @ Typeform
  • 390 replies
  • May 3, 2022

Hi @levasa 

Really impressed to see you went all the way to use webhooks ðŸ¤¯
Kudos to you!

While this solution works you could also use Zapier or Integromat/Make if you don’t know how to code.


  • Typeform
  • 4 replies
  • May 3, 2022

Hello @levasa Im the product lead at Typeform working to improve our Mailchimp integration. 
I’m working on a new feature (to map your hidden fields to mailchimp so that the integration can work without having to set up an email question) right now that I’d love your feedback on to solve your problem. Can you please schedule a meeting directly with me at https://calendly.com/chatwithjuliekim/30min

 


Gabi Amaral
Ex–Typefomer
Forum|alt.badge.img+5
  • Ex–Typefomer
  • 1777 replies
  • May 3, 2022

Wow, amazing @levasa! I'm really impressed! ðŸ˜Ž

@Michaela can you explain how we can get this done using Make (in case the customer doesn't know how to code)? Thank you! ðŸ’™


Michaela
Forum|alt.badge.img+6
  • Certified Partner
  • 189 replies
  • May 6, 2022

Hello friends, hope everyone’s well ðŸ˜Š

 

@Gabi Amaral Happy to jump in with a bit of that no-code Make insight! ðŸ¤“

 

You could go about solving this by building a scenario that would watch your Typeform submissions and add/update your subscribers in Mailchimp. 

 

Generally speaking, when a new response is submitted to Typeform, all response details, including hidden fields, are available: 

 

That means you can then easily map any Mailchimp field with the matching Typeform form response: 

 

 

 

 

There are tons of things you could automate with Make, Typeform and Mailchimp/ If you’d like to learn more about the options, you can check out the features of the pre-built integrations we have on Make:

🖤  Typeform

💛  Mailchimp

 

Have a great rest of your day, everyone!