Text Blaze can use the {urlsend} to save data when you use a snippet. This data can include anything you use in your snippet such as form values.
The following instructions outline how to use this command to save data to a Google Form and Google Spreadsheet.
Step 1: Create Your Snippet
We'll create a simple order form where we enter the name of the company purchasing our product and the size of the product they purchased.
Order Summary:
Company name: {formtext: name=Company}
Product Size: {formmenu: name=Size; Small; default=Medium; Large; Extra Large}
Step 2: Create a Google Form
Go to Google Forms: Sign-in and create a new form
Add a new "Short Answer" question for each piece of data you want to save.
I've created an example form ({sendurl} Example Form) that includes three fields: the time the snippet was used, and the values of two the form fields.
Step 3: Create a Pre-filled Link for Your Form
In Google Forms, click the "triple dot" menu icon and select "Get pre-filled link".
In each of the fields enter a unique value that you will remember. I'm going to use "time" for the time field, "name" for the company name field, and "size" for the product size field.
Then click "Get Link" and then "Copy Link".
The link I get is this:
https://docs.google.com/forms/d/e/1FAIpQLSeU5I5sK3yLLBrM_MSHlzMFOsmiOHeyl65DVowF7lqLzZf08g/viewform?usp=pp_url&entry.246620029=time&entry.1386064183=name&entry.1477738060=size
We're going to use this link in the next step. Please note that "time", "name" and "size" appear in it.
Step 4: Update the Link
You now need to make two changes to the URL
Change 1
Replace "viewForm" with "formResponse". The url will now be:
https://docs.google.com/forms/d/e/1FAIpQLSeU5I5sK3yLLBrM_MSHlzMFOsmiOHeyl65DVowF7lqLzZf08g/formResponse?usp=pp_url&entry.246620029=time&entry.1386064183=name&entry.1477738060=size
This tells Google forms we want to submit the data rather than just view the form.
Change 2
Replace "time", "name" and "size", with Text Blaze commands to include the relevant data from our snippet. This will result in:
https://docs.google.com/forms/d/e/1FAIpQLSeU5I5sK3yLLBrM_MSHlzMFOsmiOHeyl65DVowF7lqLzZf08g/formResponse?usp=pp_url&entry.246620029={time: LLLL}&entry.1386064183={=urlencode(company)}&entry.1477738060={=size}
We use the {time} command to get the current time and {=} to insert the values from our two form fields.
The urlencode
function will make sure that any characters work in the URL (otherwise you have to be careful about characters like =
or &
as they can break the url).
Step 4: Add the {urlsend} command to our Snippet
The {urlsend} command is given a URL that it loads when the snippet is inserted. We use the URL we created in the step above.
Order Summary:
Company name: {formtext: name=Company}
Product Size: {formmenu: name=Size; Small; default=Medium; Large; Extra Large}
{urlsend: {sendurl} Example Form{time: LLLL}&entry.1386064183={=urlencode(company)}&entry.1477738060={=size}; trim=yes}
We add the trim
attribute to the {urlsend} command to remove whitespace so we don't get extra new lines when we insert the snippet.
Mission Accomplished
That's it! You can now use your snippet and your Google Form will be automatically populated as you do. Google forms also let you create a Google Sheet with the responses. You might want to give it a try.
Note that the {urlsend} command works with any website, not just Google Forms. So if you have your own systems you can use the {urlsend} command to integrate with them.
Keywords: Google Forms, Google Sheets, Prefill