Platform Guide

Shopify Contact Form

Add a contact form that emails you to a Shopify store page

Last updated

To add a contact form that emails you each message to a Shopify store, paste the plain HTML form below into a Custom Liquid section or block in the theme editor. The form posts to https://api.staticforms.dev/submit with your form's API key, and Static Forms emails each submission to you. The form needs no script, you write the fields yourself, and you need no app. It works on the Static Forms free plan.

1. Copy the form

Replace YOUR_API_KEY with the key from the General tab of your form in the app, and https://YOUR-STORE.com/pages/thanks with the address of a thank-you page in your store. The key is visible in the page, which is expected: the form API key cannot read submissions.

contact-form.html

The visitor's email field becomes the reply-to address on the notification, and every other named field appears in the email, so add a phone or order-number field the same way. redirectTo must be a full URL. Without it, the visitor sees a plain confirmation from Static Forms instead of a page in your store. Your theme styles the fields, so the form takes on its look.

2. Add it to your store

1

Open the theme editor

In your Shopify admin, go to Online Store > Themes and click Customize on the theme you want to change.

2

Add a Custom Liquid section or block

Open the page that should carry the form, such as a page with its own template, and add a Custom Liquid section or block where the form should appear. If your theme does not show this option, check its documentation or ask its developer.

3

Paste the form and save

Paste the code into the Custom Liquid box and save.

Shopify's help on customizing sections notes that a custom Liquid block in the header or footer shows on every page, so add the form to a page body, not to the header or footer, unless you want it everywhere.

3. Test it

Open the live page, send a message and check that you land on your thank-you page. The message arrives by email and is listed in the Inbox in the app.

Domain restriction

If you turn on domain restriction (Starter and up), add every domain your store is served from, including your custom domain, and send a test message from each. A domain that is not on the list is rejected with a 403 that names it. Adding a domain lets every page on it submit, so you may prefer to leave domain restriction off for this form.

Optional: stay on the page after sending

If you would rather show the confirmation in place, use this version, which sends the form with a script and leaves out redirectTo. We have tested this code on a plain page, but not inside a live Shopify theme. We have not confirmed that a Custom Liquid box runs a <script>, so test it on an unpublished copy of your theme first. If it does not run, use the form above.

contact-form-with-script.html

Spam protection

Every submission goes through the built-in spam filter, and the honeypot field catches bots that fill in every field. CAPTCHA widgets and their field names are in the plain HTML guide. For Shopify's own contact form instead, see the Shopify Liquid section tutorial, which builds a section that keeps Shopify's native delivery.

Troubleshooting

What you seeWhy, and what to do
No Custom Liquid option in the editorYour theme may not offer it. Check the theme's documentation or ask its developer.
401 "Invalid API key"Check that the apiKey value matches the key on the form's General tab, with no extra spaces.
The visitor sees a plain confirmation, not your pageThe redirectTo value is missing or is not a full URL.
A field is missing from the emailGive the input a name attribute.
403 "Submission rejected: Domain … is not in the allowed domains list"Domain restriction is on and the domain the visitor used is not listed. See the domain restriction note above.
No email arrivesCheck your spam folder, then the Inbox in the app: if the submission is listed, the problem is delivery.

FAQ

Does this work on the free plan?

Yes. The snippet only uses Free plan features: 250 submissions every 30 days, 1 form endpoint, email delivery, the built-in spam filter, a honeypot field and reCAPTCHA v2. No credit card is needed.

How do I keep spam out?

Every submission is checked by the built-in spam filter on every plan. The snippet adds a hidden honeypot field (any field whose name contains "honeypot"); bots fill it in and those submissions are dropped. reCAPTCHA v2 is available on Free. Cloudflare Turnstile, hCaptcha, ALTCHA and reCAPTCHA v3 are available from the Starter plan.

Is it safe to put the API key in my HTML?

Yes. The form API key is meant to be public. It cannot read your submissions or sign in to your dashboard.

Do I need a Shopify app?

No. The form is plain HTML in a Custom Liquid section or block, with no script. It posts to https://api.staticforms.dev/submit and Static Forms receives the submission.