11
votes

The scenario goes:

  1. Via email, a Google Form is sent to a respondent.
  2. Via this sent email, the respondent answers the form and sends their response. This form has no email address field.
  3. I need to retrieve the respondents e-mail address and add it to the spreadsheet where the Google Form responses are recorded.

Via Google Apps script, is it possible to retrieve the respondent's e-mail address in this manner? For specific reasons, I am not allowed to inquire the respondent's e-mail address. Retrieving the e-mail address in this manner also serves as verification so that it is verifiable which of the e-mail addresses I sent the form to have a response.

I am aware that if you have a field which contains the user's e-mail address, this is very do-able. There is even a tutorial specifically about it. However, I haven't seen a guide for the use case described above.

I have attempted using Session.getActiveUser().getEmail(). However, it seems that it only retrieves my own e-mail address (as it considers me, the person viewing the spreadsheet, as the active user).

2
There's a reason you can't do this: it's a gross invasion of privacy.user1864610
I was not aware of that. Can you please cite a reference for that? Are you aware of any permission settings which can be clarified with the form responder? Also, why the downvote? :)brain56
possible duplicate of Hidden Field in a Google form. The title of the question is different... but the answer is the same. Using a Google Form, you can't surreptitiously trace respondents. And that's a good thing.Mogsdad
As such, it looks like Apps Script for Google Form is almost useless as we can't do much of the personalization features based on respondent's login ID. Even though you can detect the login user ID, you still can't do much on-the-fly in the onOpen() trigger. What is the point of having the onOpen() trigger works for form owners when they can easily drag-n-drop in the design view? You can't dynamically prepopulate the form either unless using the pre-fill link. To be honest, I don't see any great value for Apps Script as far as the Google Forms is concerned.Antonio Ooi
I could not agree more with Antonio. The whole point of forms in general, is to make it easy for people with poor IT skills - not to make it difficult because people think you can take over the world with peoples email address. Besides. Nothing is "picked up", before user sends SUBMIT. If you dont like the sender, dont press SUBMIT I know, Its mind blowing.Christian

2 Answers

15
votes

This can only be done if you are using Google Apps for Business, Google Apps for Education, or Google Apps for Your Domain, and are having users on your domain fill out the form. In that case, you can use getRespondentEmail() to retrieve the submitter's email address.

If your situation doesn't meet the requirement above, Google does not expose the submitter's email address to you and your only option is to prompt them for it on the form.

-3
votes

In the Form Designer, go to settings. Check Collect Email Address