Site access - Add age verification to your online store

Topic summary

A tutorial explains how to add age verification to Shopify stores selling age-restricted products like alcohol or tobacco. The implementation uses a custom snippet that displays a popup requiring visitors to confirm their age or enter their birthdate.

Key Implementation Details:

  • Creates an age-check snippet in the theme’s Snippets folder
  • Sets a cookie (isAnAdult) that prevents re-prompting for 2 weeks
  • Supports both simple yes/no verification and date-of-birth picker options
  • Includes fallback for users with JavaScript disabled

Common Issues Reported:

  • Mobile display problems: Popup appears overly zoomed or as a grey page on mobile devices
  • Age calculation bug: Date-of-birth verification incorrectly requires users to be 1 month older than the specified age threshold
  • Theme editor interference: Age verification popup blocks the Shopify theme customization preview screen and won’t dismiss when clicking Enter/Exit buttons
  • Cookie persistence: Users want options to show the popup on every visit rather than storing the 2-week cookie

Customization Requests:

  • Applying verification to specific collections/pages instead of the entire site
  • Removing background for SEO purposes (transparent overlay)
  • Styling modifications for buttons and text alignment

Important Caveat: This method does not meet FDA regulatory requirements for tobacco/e-cigarette sales and relies on user honesty.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

Hi there

Did anyone figure this out?
I would like to have pop ups just on certain products?

1 Like

I’m wondering if there is a way to exclude a category in the store from displaying the age check?

1 Like

And how do I change the language? That is, so that this message appears in Spanish for example

Hi @LavishBongs

Thanks for your coding!

I’ve tried to implement the EXIT and ENTER button design changes on the site I’m working on but the boxes aren’t appearing. Do you know why that may be?

I’ve looked into the theme set up but can’t find anything glaringly obvious there.

I don’t know my way around coding so unsure as to where to look to correct this.

Help would be VERY much appreciated - the site is currently password locked but if anyone thinks they could help let me know and I’ll turn it off.

Many thanks

Gill

I got the age verification box up, but now it just idles there after you enter your date of birth and hit enter. It never goes away.

Sounds like you need responsive css styling on your modal/pop-up so that it renders correctly on mobile.

Is there a way to add to a specific product ?

1 Like

Hi, Thanks for this very helpful lesson towards the age verification.

I believe most people have the same issue as I do, we want our pop-up shows right away, not two weeks later, so, would you please explain how to delete the cookie “isAnAdult”? Thanks a lot!

Did you find a solution?

Hi,

This is great and work perfectly fine on both desktop and mobile, thanks!

But in order for SEO to work the background would have to be transparent so Google can read the landing page. Do you have a code to add for that?

Best regards,

Björn

2 Likes

What is great and works perfectly? Not sure if I missed something.

To remove the background make this adjustment. You can also choose to just change the 4th rgba value to “0”

#prompt-background {> background: none; url(“{{ ‘age-check-background.jpg’ | asset_url }}”) no-repeat center center fixed rgba(0,0,0,0.5);> -webkit-background-size: cover;> -moz-background-size: cover;> -o-background-size: cover;> background-size: cover;> width: 100%;> height: 100%;> position: fixed;> left: 0;> top: 0;> z-index: 9999999;> }

1 Like

Has anyone been able to figure out how to apply the age verification to a collection rather than the entire page yet? If so, can someone please help me with the coding information and format??

so how to make it pop up every time when customer visit the website?

Is there a way to create an age verification that requires an email address like the example attach please? https://cdn.shopify.com/s/files/1/0254/2918/0496/files/Screen_Shot_2021-03-10_at_12.01.35_AM.png?v=1615356440

@mememonster

Yes you can send email or SMS links that will capture your customer’s real government issued drivers license or passport with Real ID.

It also can integrate directly into your checkout or on account registration on your Shopify site as well.

The app takes care of securely capturing your customer’s ID through their mobile device. It uses specially trained A.I. to verify the document and pairing selfie’s authenticity.

First 10 ID checks are free: https://app.shopify.com/real-id

Thanks for this code it worked for me! Does anyone know a way to make the website have a dark transparent layer around the button until it is clicked?

Hello, I am having trouble putting a picture in the background, could you possibly go into more detail? And also, how to I update the age verification to the correct date? >5/21/2000

Hi all,

When I centre the {% capture adult_text %} it changes the colour to green, instead of the black that it is when not entered.

Can anyone help me fix this?

Thank you!

Hiii

I had great success adding the age restriction but as i don’t sell restricted items now I wish to remove it, and am struggling to find out how.

Thanks if you could let me know that would be much appreciated