Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

One Click Submit a Google Form

The process below will allow you to submit a google form by clicking a single link. Documenting because I never seem to remember.

Initial steps:

  • Get the id of the form, located after the /d/e portion of the Form URL
  • Grab the textarea name from the Google Form page source. I normally do a manual search entry. and find the form field name from there.

The "New" Google Forms would show

<!-- formatted for readability -->
<input type="text" 
    class="quantumWizTextinputPaperinputInput exportInput" 
    jsname="YPqjbf" 
    autocomplete="off" 
    tabindex="0" 
    aria-label="Enter Your Age" 
    aria-describedby="i.desc.1524225339 i.err.1524225339" 
    name="entry.1366940499"
    value="" 
    dir="auto" 
    data-initial-dir="auto" 
    data-initial-value=""/>

Click to see the textarea of the "old" Google Forms

<textarea name="entry.1366940499" rows="8" cols="0" class="ss-q-long" id="entry_1366940499" dir="auto" aria-label="Enter your age" aria-required="true" required=""> </textarea>


  • In the above example, you need the value of name.
    • In the "New" Google Forms example above, this value is entry.1366940499
    • Be sure to only use the value of the name parameter, not the id or i.desc
  • Once you have collected all of the entry fields, you may begin to construct the url:
  • Base URL snippet: https://docs.google.com/forms/d/e/FORMID/formResponse?&[entry.number=value]&submit=SUBMIT
  • Replacing FORMID, entry, and value, you have a url that will submit a form when used with curl (bash), UrlFetch (Google Apps Script), or pasted into your browser.

A live example

link: https://docs.google.com/forms/d/e/1FAIpQLScJqX5YrRP8Q6sQsx3dCvTjwkv0byizdD2_IvJM5i2CAz-GPw/formResponse?&entry.244206211=35&submit=SUBMIT

  • Click the link above to submit the form, or do the following:
    • Copy the link and paste it into the address bar in your browser or text editor
    • Edit the url to change the value of entry.244206211 to any value of your choosing
      • NOTE: Editing the url in Microsoft Word or Excel will cause the form to submit three times. Not sure why, but I will update when I have more information (thanks for letting me know!)
    • Hit Enter to submit the form
  • View your submission in the responses sheet, linked below
  • View the form responses here

Auto Submit A Form

Be Advised: This may not be the best method.


A simple javascript fetch() command can be used to automatically submit the form on page load using something like <body onload="submit(answer)">.

function submit (answer) {
  answer = encodeURIComponent(answer)

  var formId = '1FAIpQLScJqX5YrRP8Q6sQsx3dCvTjwkv0byizdD2_IvJM5i2CAz-GPw'
  var queryString = 'formResponse?&entry.244206211=' + answer + '&submit=SUBMIT'

  var url 'https://docs.google.com/forms/d/e/' + id + queryString

  var opts = {
    method: "POST",
    mode: "no-cors", // apparently Google will only submit a form if "mode" is "no-cors"
    redirect: "follow", 
    referrer: "no-referrer"
  }

  return fetch(url, opts)
}
@ziv-caspi

This comment has been minimized.

Copy link

@ziv-caspi ziv-caspi commented Sep 24, 2019

Been looking for a solution for this for a while, Thank you!
Will update if works for me

@sabgaby

This comment has been minimized.

Copy link

@sabgaby sabgaby commented Jun 1, 2020

This is great! thanks!

I am new at this, so, how would you go about to only accept answers from a specific email? If I collect emails, it will prompt to confirm to submit the form under the signed-in email address, so it will not auto-submit.

I created a Punch Clock for employees that works with NFC fobs with a prefilled auto-submit URL written in them. Works great atm.. but eventually need to only accept answers from specific emails/users.

Any ideas?

@ajahuanex

This comment has been minimized.

Copy link

@ajahuanex ajahuanex commented Jun 19, 2020

Did someone work?
share the code please

@ohidurbappy

This comment has been minimized.

Copy link

@ohidurbappy ohidurbappy commented Sep 23, 2020

Editing the url in Microsoft word, submits the form 3 times, because the program retrieves (visits the url) the title, preview of any url you work with int the docuement. That causes the submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.