How to track verified users (logged-in vs guest) per store in a Shopify app?

Topic summary

A developer built a Shopify age verification app and needs to track analytics per store, specifically:

Requirements:

  • Count total users who completed age verification
  • Distinguish between logged-in customers vs. guest users
  • Separate data by individual merchant stores

Proposed Solution:

Detecting login status:

  • Use a theme app extension with Liquid templating to check customer login state
  • Set a JavaScript flag (window.customerIsLoggedIn) based on whether {% if customer %} evaluates true

Identifying the store:

  • Access shop data via the Shopify.shop JavaScript object
  • This provides necessary store identification information

Storing analytics:

  • Send collected data to the app’s backend using Ajax requests
  • Post to custom API endpoints for database storage
  • Alternative approaches include Shopify Functions or App Proxy, though custom APIs are more commonly used

The discussion remains open for additional implementation details or alternative approaches.

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

Hi everyone,

I’ve developed a Shopify app similar to Age Verify that shows an age verification popup to users when they visit a merchant’s store.

I want to track and display the following analytics on my app’s dashboard (analytics page):

  • How many users visited the storefront and completed the age verification process.

  • Out of those, how many were logged-in customers and how many were guest users.

  • These stats should be separated per store, as multiple stores (e.g., Store A and Store B) might install my app.

So for example:

  • Store A: 150 users verified → 80 logged-in, 70 guest

  • Store B: 200 users verified → 50 logged-in, 150 guest

My questions:1. What’s the best way to detect whether the user is logged in or a guest on the storefront from within my app’s script or popup?

  1. How can I track this data and associate it with the respective store using Shopify APIs or storefront methods?

  2. Are there recommended best practices or endpoints for storing this kind of tracking data for analytics?

Any guidance or examples with code in nodejs would be really helpful. Thanks in advance!

Hello @damonrcr

  1. You can make the theme app extension embedded and get the customer log in info like this
{% if customer %}
<script>window.customerIsLoggedIn = true;</script>
{% else %}
<script>window.customerIsLoggedIn = false;</script>
{% endif %} 
  1. So with the first step you have tracked the data. Now you need ths shop data. Get the shop data like below.
console.log(Shopify.shop)

This Shopify object has all the data related to the shops. Now, you need to hit the app route with this data using Ajax and post it into your database.

  1. Most of the apps use Ajax and the app’s custom api to grab and post this data. You can check Shopify Function and App Proxy. But I have seen most apps hitting their own api endpoint for that.
1 Like