Insert custom fields to your theme’s customer registration form
- Locate custom fields in the code
- Step 1:Step 2:Step 3:Step 4:
Do you want to gather valuable insights about your customers right from the start? In this article, we will guide you on how to insert custom fields to your theme’s customer registration form in Shopify allows you to collect more than just the basics. Let’s explore how to add those custom fields and unlock a deeper understanding of your customers.
How to insert custom fields to your theme’s customer registration form:
Locate custom fields in the code
Step 1:
Go to Online Store > Themes from your Shopify Admin panel.
Step 2:
Look for the theme you want to edit and click Actions > Edit code.
Step 3:
Tap
customers/register.liquid
located in teh Templates directory.Step 4:
Look for the Liquid tags below in the code:
{% form 'create_customer' %}
and
{% endform %}
Step 5:
You can find the contact form code between the Liquid tags that you found in the former step. This is the place the dafault form fields are found, with every field divided by an empty line. Each theme is different from each other but in general, a customer registration form field looks like this:
The code will be pasted for your custom fields after, before, or even in between the available fields, it depends on your preference. The code you add will rely on the form field’s type that you want to generate.
Step 6:
Tap Save after adding the code for the custom form fields.
4 Categories of form fields
Here are some examples we listed below for you:
Text field
Please paste and customize the code given below to generate a text field for the customer registration form:
<label for="CustomerFormAllergies">Allergies</label> <input type="text" id="CustomerFormAllergies" name="customer[note][Allergies]" placeholder="Allergies">
Radio buttons
Please paste and customize the code given below to generate a set of radio buttons for the customer registration form:
<label>Do you prefer tea or coffee?</label><br> <input type="radio" id="CustomerFormTea" name="customer[note][Tea or Coffee]" value="Tea" /> Tea<br> <input type="radio" id="CustomerFormCoffee" name="customer[note][Tea or Coffee]" value="Coffee" /> Coffee
Drop-down menu
Please paste and customize the code given below to generate a drop-down menu for the customer registration form:
<label for="CustomerFormFlavor">Choose a flavor</label> <select id="CustomerFormFlavor" name="customer[note][Flavor]"> <option>Chocolate</option> <option>Vanilla</option> <option>Strawberry</option> </select>
Checkbox
Please paste and customize the code given below to generate a checkbox for the customer registration form:
<label for="CustomerFormKitten">Would you like a free kitten?</label><br> <input type="checkbox" id="CustomerFormKitten" name="customer[note][Kitten]" value="Yes, please!" /> Yes, please!
How to customize your form field
You may need to modify the code from the examples mentioned above before saving them to your template of customer registration form to configure your form fields.
The name attribute
We need to emphasize that it is necessary to let
<select>
and<input>
elements have aname
attribute which is set tocustomer[note][Some Text]
, the place thatSome Text
specifies what question the fields is findling to respond. Because thecustomer[note]
enables the information to be submitted as a customer note so thecustomer[note]
is considered so important that nothing will be submitted without it. The only part of thename
attribute that you ought to modify must be the text located between the second set of square brackets.The value attribute
The
value
attribute is included for checkboxes & radio buttons to get the value of the selection of the customers indicated. You are able to make changes to the wording to meet your expectation.The label element
Every form field type does have an element called
<label>
. That label can display the title for every form field. Thefor
attribute can link a label to an associated<select>
or<input>
element. The labels for form fields are hidden in some themes and in that case, only the placeholder is dipslayed.The placeholder attribute
The
placeholder
attribute can be used for an<input>
element. By default, the placeholder text is what displays in the text box, before a response is typed in, for a text field. The labels for form fields are hidden in some themes and in that case, only the placeholder is dipslayed.The
for
attributeThe
for
attribute can link an element, which is called<label>
, to a<select>
or<input>
element that does have an<id>
with the similar assigned value. Let’s look at the example below:<label for="CustomerFormAllergies">Allergies</label> <input type="text" id="CustomerFormAllergies" name="customer[note][Allergies]" placeholder="Allergies">
In the example mentioned above,
CustomerFormAllergies
is the assignedfor
value of the<label>
element, also does theid
of the<input>
element:Conclusion
This article has outlined the methods for adding custom fields to your Shopify store’s customer registration form, empowering you to gather valuable customer insights and personalize your shopping experience. When implementing custom fields, prioritize user experience by keeping forms concise, providing clear instructions, and ensuring mobile responsiveness for a smooth and engaging signup process.
Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.Related Post
-