To track purchase events in the app, please ensure the below pixel is Added to your Shopify.
Step 1 - Navigate to your Shopify Admin
Step 2 - Go to Shopify Settings
Step 3 - Go to 'Customer Events'
Step 4 - Click on Create
Step 5 - Name the pixel 'Appbrew'
Step 6 - Place the following code in the pixel
function sendEvent (event, payload) {
if(window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(JSON.stringify({
action: "SEND_EVENT",
payload: {
event,
payload,
source: "web-pixel"
}
}))
} else {
window.parent.postMessage({
source: "web-pixel",
event,
payload
}, window.location.origin)
}
}
console.log("pixel", window)
analytics.subscribe('all_events', (event) => {
console.log(event.name, event.data.checkout)
sendEvent(event.name, event.data.checkout)
});
Step 7 - Click on 'Save'
Step 8 - Click on 'Connect'
You are all set!