Setup purchase pixel

To track purchase events in the app, please ensure the below pixel is Added to your Shopify.

Steps:

  1. Navigate to your Shopify Admin

  2. Go to Shopify Settings

  3. Go to 'Customer Events'

  4. Click on Create

  5. Name the pixel 'Appbrew'

  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)
});

  1. Click on 'Save'

  2. Click on 'Connect'

You are all set!

Last updated

Was this helpful?