What to use for Headless Shopify Analytics?

I have a Next.js headless set up with Shopify as the backend. I’m wondering how I can get Shopify analytics for my front end? Currently, the analytics will only track if someone is on the check out page, but I would like to see when they’re on my site as well.

I know there’s options like GTM/GA4 and other services like Elevar, but I was wondering if Shopify has something for headless (like Hydrogen). Am I able to use Hydrogen library for my Next.js front end?

Hydrogen comes with built-in analytics. It’s source-available, but you might need to rework the code to work in your Next app. Check the sendToShopify function

@not.sadsciencee Am I able to just use Hydrogen library with my Next.js front end? Or would I have to re-write the code into my Next.js app?

Personally haven’t tried it, but sure, give it a try before you start copy/pasting functions. You might be able to get away with just using the Hydrogen hooks for analytics. A lot of Hydrogen 2.0 is based around Remix/RR7 so there’s going to be some things that won’t line up cleanly with Next, especially when it comes to data loading / server mutations.

Hey! Just moved this over to the hydrogen/storefront API topic :man_running: