Saving Snippet Forms to Google Spreadsheets

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

3 Likes

This is very helpful and I can see a lot of uses for it. Just made a form to keep track of student extra credit when they earn it so I don't have to open the gradebook every time I want to enter it.

Thanks!

Mike

@scott I wonder - could something like this be used to track usage of snippets in folders that are shared with other users? For example, I maintain 5 folders containing roughly 40 snippets with a number of users. I wonder how I might go about using the above methods to populate a list tracking every time any of the users uses the respective snippets. Thoughts?

Yes, if all the users were part of the same Text Blaze organization, you could use this for that.

1 Like

Hi Scot,

Using site command, I am getting a text from a website i.e. 21/10/2015. I am using your urlsend snippet to fill it up in google sheet using google form . However, date is not getting filled up in the form and it remains blank. What I understood so far is that, the format of the date in google form DD-MM-YYYY whereas my output from website is different.

I tried using replace function {=replace(date,"/","-") but this is not working.

Can you please help what's best I can do?

Sorry, don't know how Google Forms stores dates. I would recommend using a regular text field in the Google Form if you can so you don't need to worry about the format.

1 Like

Thank you for the suggestion @scott. I will try this.

The part I am struggling to figure out is this. How do I capture the name of the snippet itself when using the urlsend to a google form? I am trying to have a list populated every time a user across my teams runs a snippet. I am trying to capture the username, date snippet run, and name of snippet itself. I know I could create a variable that itself is the name of the snippet, then pop that into the urlsend address, but, if the name of the snippet ever changes, even by 1 character, then I'd have to change the variable name too. Would love to make this as unnecessarily complicated as possible. Any thoughts / ideas?

@Brad_Hedinger - I think this is what you're looking for:

Thank you! That is on the right track. I need the name (Label) of the snippet itself though. Pulling the shortcut or the id does not give me what I want. I suppose I could use Data Blaze to build a simple table containing all my teams snippets and their unique id's. Then somehow get the snippet name (Label) from there. Seems to me though that I should be able to use the {snippet} command itself to pull this. Thoughts?

Running into an issue with this. If a snippet contains an imported snippet, then the urlsend function sends an additional record of the snippet running for every snippet that is imported. Here's an example:

I have a snippet shortcut that is *bcoe. The snippet imports 3 other snippets when it runs. Therefore, the Google Form gets the run record a total of 4 times:

10/1/2022 17:02:55 October 1, 2022 bhedinger@fullsail.com *bcoe
10/1/2022 17:02:55 October 1, 2022 bhedinger@fullsail.com *bcoe
10/1/2022 17:02:55 October 1, 2022 bhedinger@fullsail.com *bcoe
10/1/2022 17:02:55 October 1, 2022 bhedinger@fullsail.com *bcoe

Here is the coding for how I am capturing the info and sending it to the Form.

{note: preview=no; trim=yes}{snippet: shortcut}{user: email}{time: LL}{urlsend: Text Blaze Usage{time: LL}&entry.1182984646={user:email}&entry.2003404786={snippet:shortcut}}{endnote: trim=yes}

Any thoughts on this one gang?

Currently, the {snippet} command doesn't support that function. But you could post a feature request in the Suggestions forum.

That's strange. The documentation says the following:

The {snippet} command will always refer to the snippet that was initially triggered by the user even if the command is nested within an imported snippet.

This means that if the {snippet} command is used within an {import} command, the {snippet} command will still refer to the initial snippet that was triggered, not the snippet being imported with the {import} command.
Text Blaze | {snippet}

Maybe @scott can shed some light on this.

1 Like