Skip to content
Advertisement

Shopify Webhooks: How do I run JavaScript when a Webhook is triggered?

I want to setup a Shopify Webhook on the Order Cancellation event that will cause some javascript code to be run.

In this specific case, I want to send a negative transaction to Google Analytics to remove the transaction when an order is cancelled (as described here: https://support.google.com/analytics/answer/1037443?hl=en )

I have my callback url / page setup (PHP) and it works correctly when loaded in a browser. But the webhook apparently (obviously?) does not trigger any client side code to run.

Any ideas on how I can make this happen?

Advertisement

Answer

Although this does not solve the question specifically (of running javascript via a webhook) an alternative solution for this specific case would be to use Server Side Google Analytics tracking to send the negative transaction:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement