Home > Shopify Development > Generate and include an age-check snippet

How to generate and include an age-check snippet in Shopify

Sam Nguyen
Sam Updated: March 20, 2024

Share:

Drive 20-40% of your revenue with Avada
avada email marketing

Need to add an age-check snippet to your Shopify store? Ensuring your site is compliant with age-restriction laws is crucial, especially if you’re selling products like alcohol, tobacco, or other regulated items. In this guide, we’ll walk you through how to generate and include an age-check snippet in Shopify, making it easy to protect your business and customers. Follow these simple steps to set up an effective age verification process.

How to generate and include an age-check snippet

Step 1:

Go to Online Store > Themes from your Shopify Admin panel.

Step 2:

Choose the theme you want to edit and click Actions > Edit code.

How to generate and include an age check snippet in shopify

Step 3:

Expand and view the content of the Snippets folder by clicking on it.

Step 4:

Click Add a new snippet right under the Snippet folder.

Step 5:

Name the new snippet age-check and click Create snippet. Your age-check snippet will be opened in the online code editor.

How to generate and include an age check snippet in shopify

Step 6:

Open this file on a new browser tab.

Step 7:

Copy all available codes that you see and back to your Themes page.

Step 8:

Please paste the code you have just copied into the age-check.liquid snippet in the online code editor.

Step 9:

Tap Save to save all changes.

Step 10:

Locate and click on the theme.liquid file in the Layouts folder to open it in the online code editor.

Step 11:

Scroll down a bit until you see the opening <body> tag in the online code editor.

Step 12:

Paste the code given below right after the opening <body> tag:


  {% include 'age-check' %}

How to generate and include an age check snippet in shopify This will include the age-check.liquid snippet at the very beginning of your theme file’s body content.

Step 13:

Tap Save to save all changes.

Conclusion

To wrap things up, adding an age-check snippet to your Shopify store is a straightforward way to ensure responsible browsing for age-restricted products. By following these steps, you can easily implement this feature without much hassle. Stay compliant and protect your business while providing a smooth user experience.


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.

Stay in the know

Get special offers on the latest news from AVADA.