Dynamically Pre-fill Google Forms with URL Parameters

Why? Because, connect all the things! Why else? Because the less information people have to fill in to your form, the more likely they are to complete it – especially if you are asking them to fill in information that they will have to look up! Dynamically pre-filling forms is a great conversion optimization hack to show your prospective respondents a little love. This love will increase form completion rates and response accuracy.

The question originally came to from someone who had read my post about Mailchimp Reporting with Google Spreadsheets (same products but different applications) But hey, sometimes you don’t even know where to start your Google search! His question was this:

I send a reminder email to my customers through MailChimp. The email contains the customer’s account code and some other data unique to the customers. A link on the email sends the customers to a Google Form where they will answer some questions. I want to have the customer’s unique customer code populate a field so I that I know  who the response came from, and in doing so, reduce the number of fields a customer would have to complete.

Do you have a solution for this? MailChimp and Google apps said there isn’t, but Google did suggest it might be resolved with a script (which I have no idea how to do).

It seemed interesting. I thought about the script. I was hoping this would not be the answer because that sounded like trying to breed an ostrich and an alligator. Then I remembered a project I had worked on in tracking Wufoo form submissions in Google Analytics. That was an Ostrigator but hey, it worked!

The key was passing data around on query strings. I knew there was dynamic values in Mailchimp in the form of Merge Tags. Then all we needed was a link to Google Forms that would allow you to pre-populate the forms. Lo and behold: Pre-populate form answers! So all we would have to do is match the right merge tags as to the right form URL query string parameters and we would have pre-populated forms from the dynamic values in the emails. #masscustomize all the things!

Merge Tags in Google Form Link Parameters

Step 1. Get a Pre-Filled Google Form URL

To get started, go to your Google Form editing page and click responses. Select “Get pre-filled URL”

Hubdango Google Forms

Step 2. Pre-fill the Form with Merge Tags

Find the merge tags that you want to use and enter them into the form boxes. *When you do this, make sure to use merge tags that are accurate for your whole mailing list. Missing information is not a problem but if your merge tags are inaccurate, this could cause confusion and/or complaints.

User Validation

Step 3. Copy the Pre-filled Google Form URL

The merge tags have been appended to to the form’s URL as query string parameters. Now you have your link to your Google Form that will automatically fill the values of your form with the values of your Mailchimp Merge Tags.
User Validation 2

How Query String Parameters Work

At this point, you may be wondering how this works. You have a URL that looks like this:

https://docs.google.com/forms/d/1MnRQJ3XZxsRBSVp28M7Sm1M8Gm5jniE/viewform

followed by this:

?entry.1040949360=*%7CFNAME%7C*&entry.271521054=*%7CLNAME%7C* ...

The part after starting with with the question mark (?) is the query string. It is made up of key-value pairs connected with ampersands (&). Query strings are used to pass information to webpages or “resources.” The server that handles the request will know what the query string’s keys mean and depending on each key’s value, will dynamically generate or modify the resource. (See how query strings works with a API’s) In this case, Google’s server just takes the value of each secretly encrypted key and places the value in the form field associated with that key.

But why does the ‘First Name’ Merge tag look like *%7CFNAME%7C* ?

You have seen strings on the internet, often on URL’s that have something like “%20” in them. This is called URL encoding. It is one of those web standards that allows the magic of the web to work. Because the pipe character (|) is not a normal character it is encoded after the percent symbol as “%7C” .

Don’t worry when you paste this into your Mailchimp email, Mailchimp will automatically decode the URL and it will end up looking like this:

?entry.1040949360=*|FNAME|*&entry.271521054=*|CLNAME|* ...

Now go answer every other question you have ever had about URLs.

Now that you’re back, go setup your new email campaign.
Mailchimp Merge Tags in links
Then when your email recipient and prospective form respondent gets their Mailchimp email, the link will be dynamically modified to look like this:

?entry.1040949360=Trevor&entry.271521054=Fox ...

and… Hello World! The Mailchimp has correctly rendered the links with the dynamic values from the merge tags.
Rendered links with Mailchimp Merge Tags

Digital Marketing is Science + Art

When it’s all said and done, an appealing email subject like and effective copy will only get respondents to go to the form page. After that, their is a lot left to optimize. As digital marketers, we are doing much more than trying to persuade. We are delivering a message, removing friction and optimizing experiences. We are measuring and testing all the way! Don’t forget, our job is just as much about perfecting the message as it is the medium.

To build more Digital Marketing Technical Skills checkout my $10k Tech Skills Series.

 

 

11 Comments

  1. Greg Kahn

    Trevor,

    Thank you for your time and appreciation of my problem. Your awesome knowledge, information, and quick response allowed me to get my project up running. I contacted both Google and MailChimp for help. Google suggested for me to write a script but I’m not an “alligator-ostrich breeder”. Google search engine did lead me to you in my quest for a solution though. I highly recommend you to others not just for your knowledge, but also for your way of providing it to people like me who don’t understand code, webdesign, HTML tags, etc.

    Best regards,

    Greg

  2. Sean

    Trevor, great stuff! Obviously this works like a charm for text fields. How can you make this work for radio and checkbox fields, since you can’t input the *|MERGE|* fields for those?

    1. Trevor Fox

      Hi Sean, It looks like you can still input merge tags for radio buttons and checkboxes. Radio buttons behave the same as text fields where the text of the label would be the same as the text in the input field. eg. if you had a radio button that you wanted to prefill, and the the text was “Good” then the URL parameter would be something like, “entry.2071347608=Good”. Similarly, every checkbox seems to be treated as its own questions so if you had two checkboxes that you wanted to pre-check, then it would look something like, “entry.2471307608=USA&entry.2071307408=Canada”. To make this work, you would have to label your radio buttons or checkboxes with the text that would be found in your merge tag. For more info, check out: https://support.google.com/docs/answer/160000?hl=en

      1. Sean Daigle

        Trevor, I did manage to go in and tweak the code Google forms generates for the pre-filled link. You can actually insert the *|MERGE|* tags straight from MailChimp, provided the text is the same on both forms (i.e. Google forms and MailChimp list signup form). Works like a charm!

  3. Orrin

    I’ve been using this for over a year and it works great. BUT… the NEXT LEVEL is to “hide” the encoded data in your form so that it populates on Google’s spreadsheet, but the respondent does not see (or at a minimum cannot change) the data in a field. Any solutions to this yet?

    1. Trevor Fox

      As far as I know, there is no option for this within Google Forms. I have done this with Wufoo but it requires creating an HTML page and editing the form code.

      1. Orrin

        Thanks for the info. I’m not familiar with WuFoo. For me, the key aspect of Google forms is that it returns data directly to Google Forms, which in turn communicates with Zapier and MailChimp. Do you happen to know if WuFoo has the same capability, or has the ability to return data directly to Google Forms?

Leave a Reply

Your email address will not be published. Required fields are marked *