Is there still event tracking support in onsite for current versions of Hydrogen? Is the documentation current/accurate?
Page 1 / 1
Hi @ryanfoote,
We do still support integrating with a Shopify Hydrogen store, yes, and our guides are updated to reflect the current code snippets you need. Would you mind sending over screenshots of the snippets you added to your site and letting me know where you posted them? That’ll help determine if this issue is related to how these snippets were added.
Additionally, did you integrate yet with the native Shopify integration? Despite being a hydrogen store, this step will need to happen first before the integration can work as expected.
Hey again @ryanfoote,
Just wanted to check and see if you got this solved!
Hey @Byrne C it seems that the Klaviyo Shopify app in our store is in need of an update, even though we regularly keep it up-to-date (like, as recently as a week or two ago we updated it last). We’ll make sure that the app is up-to-date and will test our event tracking integration again. I’ll be back with results!
As a sidenote, will the other Klaviyo features powered by onsite (forms, pop-ups, etc.) also not function if the Klaviyo Shopify app is technically out-of-date by days or a couple of weeks?
@Byrne C we’ve updated the Klaviyo Shopify app and our team had a question. Does “Klaviyo app embed” need to be turned on for klaviyo.track to work in Hydrogen storefronts?
Hey again @Byrne C,
Ok, our team has tested the integration again and they’re getting the same results, of which there are none. Here’s the code for the handler attached to the “add to cart” button instances in our storefront:
const handleClick = (event) => { if (typeof window !== 'undefined') { const {klaviyo} = window; if (typeof klaviyo?.track === 'function') { console.log("Klaviyo track fired: 'Hydrogen Added to Cart'"); klaviyo.track('Hydrogen Added to Cart'); } }
if (typeof onClick === 'function') { onClick(event); } };
It is definitely being fired when the integration is tested. We consistently see the “Klaviyo track fired: 'Hydrogen Added to Cart'” log output in the console.
Our team also had another question: Where in Klaviyo should they be looking to confirm whether or not a event was successfully fired? They’ve been looking for a “Hydrogen Added to Cart” event in Analytics > Metrics. Is that the right place for them to be looking?
Hi @ryanfoote,
To start, you won’t need to turn on the app embed when you’re using a headless setup. Reason being that you’re already manually installing our onsite javascript and tracking events. The app embed doesn’t work as expected on headless Shopify stores, so no need to turn it on.
As far as I know, the Klaviyo app shouldn’t need updates too frequently in Shopify, though if you’re seeing it needs an update, it’s certainly a good idea to update it before testing out the integration.
Finally, regarding Added to Cart not tracking - your team would look for it in the Metrics tab in Klaviyo. You’d search for Added to Cart in your metrics and then click it to see if any recent events came through. That being said, Klaviyo isn’t going to track every single site visitor who doesn’t identify (cookie) themselves. A site visitor needs to take an action that identifies them for them to be tracked. This can be one of several actions:
Are your active on site, viewed product and added to cart events failing to track for users who have taken these actions and cookied themselves beforehand?