Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
My main goal is to be able to have purchases forward onto a server which can then fan data out to the relevant tools.
For example, GA4 requires a `client_id` and a `ga_session_id` both which can be extracted from cookies. Ideally, if I could somehow set these as custom data points into Shopify which the webhook could later send back to me, I'd be able to stitch the user session together and fire a HTTP POST request to GA4 with the relevant data.
This would be replicated for several other platforms too.
(If there is a better way to do this feel free to share!)
Thanks,
N
Hi Nshar,
Have you looked into storing data as metafields or metaobjects which could then be referenced in webhooks? You should be able to add Metafields to orders to `store client_id` and `ga_session_id` extracted from cookies. Then you'd configure webhooks in your Shopify admin or via the API to trigger on the events you're interested in (e.g., order creation), and on your server, you'd setup an endpoint to receive the webhooks and extract the Metafield data from the webhook payload.
Would this approach work for you?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog