1

I'm trying to integrate a Mailchimp mailing list into Drupal. The Mailchimp list requires:

  • First Name
  • Last Name
  • E-Mail

The client already has a list in this format so ideally I need to collect this data in Drupal.

I want to have a newsletter block that collects the email address and forwards a user to another page that has the full newsletter sign up with first name last name and the email but pre filled out.

I know I'm going to need Rules and Webform. But how can I collect the value of the webform field and use it again as a token later?

Note: I am using this within the Drupal setup, but the list requires three fields of data (first/lastname/email). I want to have a block that initially collects the email and forwards them to the full newsletter signup page. I have the webform and rules working to direct the user from the page with the block to the signup page, but I need to find out how to create a custom token from the field.

2
  • Did you know there's a MailChimp module?
    – Clive
    Commented Nov 7, 2012 at 13:01
  • Yes i am using it within the drupal setup, but the list requires three fields of data first/lastname/email I want to have a block that initially collects the email and forwards them to the full newsletter signup page, i have the webform and rules working to direct the user from the page with the block to the signup page but i need to find out how to create a custom token from the field Commented Nov 7, 2012 at 13:19

3 Answers 3

0

Have a look at Webform Mailchimp , different approach but may be of use

Provides a webform component that lets users subscribe to a Mailchimp newsletter as they submit a webform.

0

You do have access to all labels and all values of any field of a webform, ie:

  • [data:MachineFieldName-title] contains the Label of a field with machine name MachineFieldName.
  • [data:MachineFieldName-value] contains the Value of a field with machine name MachineFieldName

So in your case, you might be able to get it to work using something like [data:email-id] (assuming that's what corresponds to the "email field" in your case).

For way more details on this, and a prototype rule about this, refer to the answer to "How to create a node from a Webform using rules?":

  • the 1st attempt relates to using "Entity has field" (which doesn't work for Webform)
  • the 2nd attempt explains what to do in case of Webform.

Even though the above is a good start, it may not be sufficient to achieve your goal (= "... how can I collect the value of the webform field and use it again as a token later ...", as in your question). However, you can use a technique similar to what is described in my answer to "How to do a data comparison to submitted webform data when using the Rules module?". For short:

  • Add an extra Rules Action to Add a variable, with a value assigned to it equal to your [data:EmailField-value-raw] (and with an appropriate data type). I'm assuming your eMail field in your webform has a machine name like EmailField (adapt to fit your machine name).
  • In your subsequent Rules Actions you can refer to the value of this variable you just added (that's the clue!).

PS: I'm assuming this question is about D7.

0

I dedicate a blogpost on how to add a custom WebformSubmitHandler to process the data. Read about it here: https://stefvanlooveren.me/blog/how-create-mailchimp-subscription-drupal-8-webform-module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.