How to Add Age Verification to Shopify – Step by Step Guide - eCommerce Thesis

How to Add Age Verification to Shopify – Step by Step Guide

If you run a Shopify store that sells age-restricted products, it’s essential to add age verification to Shopify. Age verification ensures that visitors under a certain age cannot access your website; therefore, it helps you comply with legal requirements and maintain a responsible brand image. In addition, this feature protects your business from potential legal issues. In this tutorial, I will show you step by step how to easily add an age-check popup to your Shopify store without using any third-party apps, so you can keep your website safe and professional.

Step 1: Create the Age-Check Snippet

From your Shopify admin, navigate to Online Store > Themes > Actions > Edit Code. Open the Snippets folder and click Add a new snippet. Name it age-check and click Create snippet. This will open the code editor for your new snippet.

Step 2: Add the Age Verification Code

In the age-check.liquid snippet, paste the following code:

{% assign enter_date_of_birth = false %}
{% assign age = 18 %}

{% capture adult_header %}Adults only (18+){% endcapture %}
{% capture adult_text %}This website contains adult material and is only suitable for those 18 years or older. Click Enter only if you are at least 18 years of age.{% endcapture %}

This code sets the minimum age requirement and creates the popup message for your visitors.

Next, add the dropdowns for month, day, and year, along with the Enter and Exit buttons. Then include the JavaScript to check the user’s age and redirect underage visitors to another website or page.

Step 3: Include the Snippet in Your Theme

Open Layouts > theme.liquid. Scroll to the opening <body> tag and paste the following line to include your age-check snippet at the top of your store:

{% render 'age-check' %}

Save your changes. Now, every visitor will see the age verification popup when they visit your store.

Why Add Age Verification to Shopify?

By adding age verification, you protect your business from legal risks and ensure that only eligible customers access your products. It also adds a professional touch to your store, showing that you care about responsible selling.

This method works for any Shopify theme and does not require additional apps. It’s a lightweight, effective solution to implement age verification quickly.

Pro Tips

  • Customize the popup design using CSS to match your store’s branding.
  • Set the number of days before users need to verify their age again using cookies.
  • Test on desktop and mobile devices to ensure smooth functionality.

By following this guide, you can easily add age verification to Shopify and maintain compliance while enhancing your customer experience.