How to add a Hidden Field in Contact Form
What is a Hidden Field?
A hidden field is a form element that collects data without being visible to your customers. This data is still sent with the form submission and included in your contact form emails.
When to Use Hidden Fields
Hidden fields are perfect for:
Tracking which product a customer was viewing when they submitted the form
Capturing additional context about the customer's journey
Adding internal reference numbers or metadata to form submissions
How to Add a Hidden Field
In your contact form section, click "Add block"
Select "Hidden value" from the block options
Give your hidden field a label (this is for your reference only)
Setting the Hidden Field Value
You have two options to set the value:
Option 1: Using a String Value
Simply enter the text or connect the metafield you want to capture in the "String value" field. This is useful for static or dynamic values like:
Store location
Form version
Internal reference numbers
Option 2: Using Liquid
Use Liquid to dynamically populate the field with values from your store. Here are some common examples:
Example 1: Product Title
This will capture the title of the product the customer is viewing.
Example 2: Product ID
This will capture the unique ID of the product.
Example 3: Current Page URL
This will capture the URL where the form was submitted.
Example 4: Customer Information
This will capture the customer's email if they're logged in.
Viewing Hidden Field Data
Hidden fields are not visible on the form to customers
The data will be included in your contact form email notifications
In the email, you'll see the field label and its value
Example Use Cases
Product Inquiry Form
If you want to know which product a customer was viewing when they submitted a question:
Add a hidden field
Set the label to "Product Information"
In the Liquid value field, enter:
Store Location Tracking
If you have multiple store locations and want to track which location's form was used:
Add a hidden field
Set the label to "Store Location"
In the String value field, enter your store location (e.g., "Downtown Store")
Tips
Always give your hidden fields clear, descriptive labels
Test your form submissions to ensure the hidden fields are capturing the correct data
Remember that hidden fields are only visible in the form email, not on the form itself
You can use multiple hidden fields in the same form
Troubleshooting
If your hidden field isn't capturing the expected data:
Check that you've entered the Liquid code correctly
Verify that the variable you're trying to capture is available in the current context
Test the form submission to see what data is being captured
Make sure you're using the correct Liquid syntax for your specific use case
Last updated