Past couple days I spent trying to integrate Shopify’s Web Pixels with little success and I’m not sure what I’m doing wrong.
I’m looking to either send events to my own server or fetch events from wherever Pixel events are stored for analytics purposes within my app.
I followed the documentation and did the following:
-
Setup development store with checkout extensions preview enabled
-
Set API version to ‘unstable’
-
Scaffolded a web pixels extension, built it, deployed it, and published it successfully
-
Created a web pixel configuration for my shop through the graphql API
When I browse the store I see that the pixel loads within the network tab but I don’t see any events being sent to my server. My extension code looks like this:
import { register } from '@shopify/web-pixels-extension';
register(({ configuration, analytics, browser }) => {
console.log('configuration: ', configuration);
const pixelEndpoint = `https://ktruong008.ngrok.io/pixel?id=${configuration.accountID}`;
analytics.subscribe('all_events', (event) => {
console.log('Page viewed', event);
browser.sendBeacon(pixelEndpoint, event);
});
});
What am I missing? Am I doing something wrong or is this not how WebPixels are supposed to be used?