(Advanced) Pass values into a form via email
In this article:
- Set up your form
- Create your email template
- Map your LGL form to your Little Green Light account
In development circles, we frequently hear about the importance of creating personal relationships with your donors. So, when you ask a loyal supporter to fill out a form, wouldn’t it be nice to show them that you already know certain things about them, such as their email address, mailing address, and so on?
I know I would prefer to receive a request to update a form where my contact information was already pre-populated. This form, for example, loads with contact information fields pre-populated, based on the constituent's record in Little Green Light:
This article describes how you can send people to a pre-populated form using an email sent from Little Green Light (using LGL Direct Email):
• You cannot populate forms that are embedded in your website. This approach only works when you are sending people to forms that are hosted by LGL forms (NOTE: All forms are automatically hosted by LGL, but if you publish a form directly on a webpage, such as on your website, it won't be possible for the fields to be pre-populated using the method described in this article).
• Certain characters (most notably, the "#" character) will cause issues if you try to pass them through to a form, so please avoid using special characters.
• Constituents’ best email, phone, and address information will be passed through even if they are marked as “inactive” in your LGL account.
Step 1: Set up your form
In LGL forms, create the form that you’ll be sending people to. If it’s a contact update form, you’ll likely use the standard fields for Name, Email, Phone, and Address. But you can also add other fields, such as Spouse Name.
You may want to add an option for the respondent to tell you their communication preferences as well.
For help on creating a form, see this this Knowledge Base article.
Step 1b: Make note of the field numbers in your form
You will need to know the field numbers for each field that you want to populate with data. The easiest place to find this is by going to your form and clicking through to the Confirmation area. All of your form’s fields are available on the right side of the page, and if you hover over a field name with your cursor a popup will show you the field number.
In the example below, you can see that the field “First Name” has the field value of 6 (i.e., “field_6”).
Write down the number for every field you want to populate.
The salient fields are likely to be:
Field # Form Fields
[[field_5]] Name: Prefix
[[field_6]] Name: First Name
[[field_7]] Name: Last Name
[[field_8]] Name: Suffix
[[field_11]] Address: Address Line 1
[[field_12]] Address: Address Line 2
[[field_13]] Address: City
[[field_14]] Address: State/Province
[[field_15]] Address: ZIP/Postal Code
[[field_16]] Address: Country
Step 2: Create your email template
In your Little Green Light account (remember that LGL Direct Email needs to be set up first), go to Mailings > Templates > Email Templates to create a new email template.
In the template, type the content into the template and include a link to the contact form.
Step 2b: Create the link to the form
This is where the magic happens. When you click the "Insert/Edit Link" button in the email editor, a dialog pops up where you can insert the link/URL.
The link you build will have two parts, as described below.
Part 1: The link to the form
Find the address (URL) of the form by going to the Publish section for your form in LGL forms.
Use the Publish option, in which you point people to the form hosted on the LGL forms site.
Copy this URL to an MS Word or Notes document (anywhere you can paste it for later use).
Part 2: Passing through field values
In part 1 above, you copied the URL of the form itself. Now you need to pass through the values you want to populate in the form.
After the form URL, add a question mark: "?"
Then include each field using the following syntax:
In plain English, this means “and set field 6 to be populated with the first name field.” When you send out your actual email, it will pull in (merge in) the values from each constituent into the link URL. Then, when the recipient clicks on the URL it will take them to the form and carry with it the values for the pre-set fields.
In our example, the selected fields are:
&field_6=[[first_name]] &field_7=[[last_name]] &field_9=[[email]] &field_17=[[phone]] &field_11=[[street]] &field_13=[[city]] &field_14=[[state]] &field_15=[[postal_code]]
Completing the link
Paste in the first part of the link (the part you pasted to an MS Word or Note document), add the question mark "?", and then write out the elements after the "?" Altogether, your final URL will look something like:
Note carefully that the unique ID for our form (090PIleCbO0IjBb7DnBi3Q) is indeed unique to our form. If you copy the above string, you’ll go not to your form but to ours. We provide this link, however, to show you how you can create yours.
CAUTION: Apostrophes will cause problems
If you are passing in a value that includes an apostrophe, such as a last name like O'Sullivan, or an organization name like O'Dea, this will break the link as formatted through the email server. As a solution, you could send those emails directly from your own email program, instead of via LGL Direct Email.
Step 3: Map your LGL form to your Little Green Light account
We’d be remiss if we didn’t talk a little bit about how the completed forms are going to come back into your Little Green Light account; after all, that’s the whole point of sending out the form, right?
For more information on mapping LGL forms to Little Green Light, read about passing LGL forms data to your Little Green Light account.
For our purposes here, the key things to know are:
Ideally, you'll pass the constituent_id into a hidden field in your form, and use that to match back to the correct constituent record. This is described in the section below. But, if you aren't up for that, then in your matching preferences you will likely want to allow name-only matching. Otherwise, anyone who changed their email address will fail to match when the form is re-submitted (though you could always manually match it up during review). You should therefore also leave the “Require review before saving” default setting checked. This setting sends all of your form submissions into your LGL forms Submission Queue, where you can review them before blindly saving them to your LGL account.
In the form mapping, it would be wise to add a default (which you can do by clicking “Add default” in the mapping) to set the incoming contact information as “preferred”. Because LGL allows multiple email addresses, phone numbers, and physical mailing addresses, these incoming bits of contact information will be added to the constituent record and won't automatically replace the existing data.
If you've added a field to collect the donor's preferred method of communication, you'll probably need to create a field in your LGL account to store that piece of information. Adding that as a value to your Communication Tags (formerly known simply as Tags) is a good way to handle this.
Using LGL Constituent ID to establish iron-clad matching
If you have a little energy left, there's an even better way to make sure completed forms match up to relevant constituent records in your LGL account. You can pass the LGL Constituent ID through the email into a hidden field in your form, and then map that back to LGL. In other words, just as you are passing along the first name, last name, and other fields from each constituent record into the LGL form they are filling out, you can also choose to pass along their LGL Constituent ID using the merge field [[constituent_id]].
Here's a breakdown of the steps to complete (please make sure you do them in this order):
- In your LGL form, add a Single-line input field named "LGL Constituent ID". Check the box to make this a hidden field.
- In the mapping for your form, add the mapping for this field to the Constituent type field named "LGL Constituent ID".
- Go to the Confirmation area for your form and jot down the field number you see when hovering your cursor over this ID field (something like [[field_31]]).
- Back in your LGL account, go to the email you are crafting and in the link where you are passing through the pre-populating values, include "&field_31=[[constituent_id]]" (assuming the field number you found on step 3 was indeed 31).
In summary, you are passing the LGL Constituent ID into a hidden field in the form, so when the form is returned back to LGL it can be easily matched back to the constituent record it belongs to.