How to Create an Inbox Survey in AMP for Email

AMP for Email enables powerful interactivity right inside the inbox—but it comes with strict limitations. One of the most important and useful AMP components is the form component, which lets users submit data without leaving the email. In this tutorial, we’ll walk through creating a working AMP form backed by a Google Sheet using Google Apps Script.

In traditional emails, collecting data usually means linking out to a landing page. With AMP for Email, you can collect responses directly inside the email, making actions frictionless and increasing engagement. When leveraging AMP for Email to collect customer feedback, I have seen an increase in response rates as high as 300%.

Step 1: Create the Google Sheet

For this example we'll be using Google Sheets because it is free and fast to set up, requires no backend hosting, and is accessible to anyone with a Google account.

  1. Go to Google Sheets and create a new sheet
  2. Be sure to keep the default tab is labeled as Sheet 1
  3. In row 1, add the following column headers (case-sensitive):
    • Timestamp
    • name
    • email

These column headers must match the names used in your AMP form fields.

Step 2: Set Up the Google Apps Script

Google Apps Script is a JavaScript-based cloud scripting language that lets you automate tasks and connect to Google services. In this tutorial, we'll use it to handle form submissions and write incoming data to a Google Sheet.

  1. In your Google Sheet, click Extensions > Apps Script to open the Apps Script editor.
  2. Delete any default code and paste in this Google Apps Script
  3. Save the project as AMP Form Handler
  4. By default, the script is set to doPost. Update this to run the setup function (you may need to authorize it)
  5. Click Deploy > Manage deployments > Create deployment
  6. Choose type: Web app
    • Execute as: Me
    • Access: Anyone
  7. Click Deploy, then copy the "Web App URL"

We'll use this URL to route the AMP form submissions.

⚠️ Known Limitation: Google Apps Script does not currently support the AMP-required Access-Control-Expose-Headers in its response headers. This means that even when the form is successfully submitted, you may not see the submit-success message render inside a real AMP email. However, the data will still be written to your Google Sheet.

Step 3: Build the AMP Email Form

Now let’s build the actual form that will live inside the email. This form submits data to your Apps Script Web App and provides inline success and error feedback using AMP’s built-in support for submit-success and submit-error blocks.

Include the amp-form component

In your email's <head>, you must include the amp-form and amp-mustache components:

									
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
								
Basic Form Markup

Here is a fully working AMP form you can plug into the <body> of your email:

									
<form method="post"
      action-xhr="YOUR_WEB_APP_URL">
  <input type="text" name="name" placeholder="Name" required>
  <input type="email" name="email" placeholder="Email" required>
  <input type="submit" value="Submit">
  <div submit-success>
    <template type="amp-mustache">
      Thanks for signing up!
    </template>
  </div>
  <div submit-error>
    <template type="amp-mustache">
      Something went wrong. Please try again later.
    </template>
  </div>
</form>
								
Link to your Google App Script

Replace YOUR_WEB_APP_URL with the actual Web App URL from your Apps Script deployment. Get the full code here.

This is the form users will interact with, right inside their email.

Step 4: Send a test email in the AMP Playground

In this step, we're going to preview and validate your AMP email using the official AMP Playground. This is a critical part of the process—it ensures your AMP code is valid and lets you send a live preview to your own Gmail inbox. Since AMP emails are only supported in certain environments (like Gmail on desktop), testing this way ensures everything is functioning as expected before you send it to others.

Before sending this to real users, you should test your AMP email.

  • Go to the AMP Playground
  • Paste your complete AMP email code into the editor
  • Check the Validation Status and fix any AMP compliance errors that appear
  • Click Send a test email and enter your Gmail address
  • Open the test email in Gmail (desktop or supported mobile client)
  • Submit the form — your data should be written to the Google Sheet
💡 If the submit-success message does not appear after submission, that’s expected with Google Apps Script due to AMP CORS limitations. The fallback paragraph below the form will still provide confirmation.

🚀 That's it!

Congratulations — if you’ve made it this far, you’ve successfully created and submitted a working AMP for Email form!

You’ve proven that it’s possible to collect user input right from an email message and store it in a Google Sheet—all without needing a landing page or traditional backend.

If you want to take things even further, continue reading to explore the more granular details, optional enhancements, and advanced integrations that build on this solid foundation.

Hosting the AMP Email

To send AMP emails successfully in a production environment, your email must meet a few technical requirements:

Testing tools like the AMP Playground can help validate your AMP email code.

💡 Note on CORS and Success Display:
When using Google Apps Script as your backend, you'll notice CORS warnings and that submit-success blocks may not render correctly. This is because Google Scripts do not support the Access-Control-Expose-Headers AMP requires for template rendering.
✅ Your form still works and your data is collected. You can:
  • View the submissions directly in the Google Sheet
  • Use fallback confirmation text as shown above
  • Move to a production environment that supports AMP's full CORS requirements later

Next Topics

  • How to Create a Carousel in AMP for Email
  • Create a real working loan calculator
This site uses cookies 🍪. You can't eat them but if you click "Accept" this awful banner will go away. Learn More.