To request the user to fill in their email and send this information to a Google Sheets form, you can use a Google Form linked to a Google Sheet, then submit the email data via an HTTP POST request from your application. Here’s a step-by-step guide to implement this in a C# application:
Step 1: Set Up a Google Form Linked to Google Sheets
- Create a Google Form:
- Go to Google Forms.
- Create a new form and add a field for the user’s email.
2. Link the Google Form to a Google Sheet:
- Click on Responses in the Google Form editor, which is circled red here:

- Click on the Google Sheets icon to link the form responses to a Google Sheet.
- A new Google Sheet will be created where the form responses will be stored.
3. Get the Form’s Entry ID for the Email Field:
Now, click on the 3 dots button as circled green in this image:

Then, select Get pre-filled link. A new page will pop up. Right-click on the form page, select Inspect, and look for the form field’s entry ID (e.g., entry.1234567890) for the email field. This ID will be used in your HTTP request to submit data to the form.
Step 2: Create the Unity Script
- Create a new C# script in Unity (e.g.,
GoogleFormSubmitter.cs). - Set up the script to use Unity’s
InputFieldandUnityWebRequestto send the email to Google Forms.
Here’s the full script (Click to download the codes):
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
using System.Collections;
public class GoogleFormSubmitter : MonoBehaviour
{
// Attach this to an InputField in the Inspector
public InputField emailInputField;
// Replace with your Google Form's POST URL
private string googleFormUrl = "https://docs.google.com/forms/d/e/your-form-id/formResponse";
// Replace with your Google Form's entry ID for the email field
private string emailFieldEntryID = "entry.1234567890";
public void SubmitEmail()
{
if (string.IsNullOrEmpty(emailInputField.text))
{
Debug.LogError("Email field is empty.");
return;
}
StartCoroutine(PostEmailToGoogleForm(emailInputField.text));
}
private IEnumerator PostEmailToGoogleForm(string email)
{
WWWForm form = new WWWForm();
form.AddField(emailFieldEntryID, email);
UnityWebRequest request = UnityWebRequest.Post(googleFormUrl, form);
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.Success)
{
Debug.Log("Email submitted successfully.");
}
else
{
Debug.LogError("Error submitting email: " + request.error);
}
}
}
Step 3: Set Up the Unity UI
- Create an Input Field in your Unity scene:
- Go to
GameObject>UI> Legacy >Input Fieldto add a new input field. - Set the
Placeholdertext to something like “Enter your email”.
- Add a Button for submission:
- Go to
GameObject>UI>Button. - Set the button text to “Submit”.
- Attach the Script:
- Drag the
GoogleFormSubmitterscript onto any GameObject (e.g., an empty GameObject calledFormManager). - Assign the
emailInputFieldvariable in the Inspector to your input field.
- Link the Button to the Script:
- Select your button and go to the Inspector.
- In the
On Click ()section, add theGoogleFormSubmitterobject. - Select
GoogleFormSubmitter.SubmitEmail()as the function.
Step 4: Test the Form Submission
- Run the Scene.
- Enter an email in the input field and click the submit button.
- Check your Google Sheet to see if the email was added correctly.
Important Notes
- Ensure the Google Form and the Google Sheet permissions are set to allow access without signing in.
- This approach relies on Google Forms being open for submissions from anyone with the link.