Skip to content

Instantly share code, notes, and snippets.

@bougsid
Created October 12, 2023 12:37
Show Gist options
  • Save bougsid/11553a17a3805832bf880a9251f9aefc to your computer and use it in GitHub Desktop.
Save bougsid/11553a17a3805832bf880a9251f9aefc to your computer and use it in GitHub Desktop.
window.es_hook_purchase_success_func = (order) => {
//You can find the order object format here: https://shopify.dev/docs/api/admin-rest/2023-07/resources/order
if (typeof fbq === "function") {
let data = {
value: order.totalPrice,
num_items: order.itemCount,
currency: window.ShopifyAnalytics.meta.currency,
};
data.content_ids = order.items?.map(item => item.product_id);
data.content_type = "product_group";
window.fbq(
"track",
"Purchase",
data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment