App reviews, troubleshooting, and recommendations
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
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
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?
How can I track this data and associate it with the respective store using Shopify APIs or storefront methods?
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!
Solved! Go to the solution
This is an accepted solution.
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 %}
2. 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.
3. 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.
This is an accepted solution.
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 %}
2. 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.
3. 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.