Hi guys, I would really appreciate some help.
No matter what I try to set up customer events for a custom trigger on meta pixel it wont work.
In short we have sample orders and full size orders, ive set up two custom events including all the product ids.
However every time I try a test purchase it defaults to the standard partner integration and purchase - rather than the custom event “sample purchase” or full size purchase.
I have tried adding to the post script, the customer event and liquid theme. nothing works.
when attempting to manually trigger it in the console it fires in event manager on meta, but it just wont seem to automatically fire.
Maybe it’s a limitation of the integration?
here is the code for customer event.
// Subscribe to Shopify’s Checkout Completed Event
analytics.subscribe(“checkout_completed”, event => {
let orderValue = event.data.totalPrice.amount;
let currency = event.data.totalPrice.currencyCode;
// Sample Product IDs
let sampleProductIDs = [“9745311531314”, “8187445575986”];
// G Add-on (only counts if ordered with a sample)
let sampleGummiesIDs = [“9752827658546”, “9683579142450”, “8198308430130”];
let hasSample = false;
let hasG = false;
// Loop through all purchased products
event.data.products.forEach(product => {
let productID = product.id;
let productTitle = product.title;
if (sampleProductIDs.includes(productID)) {
hasSample = true;
}
if (sampleGIDs.includes(productID)) {
hasG= true;
}
});
if (hasSample) {
// Track Sample Purchase (with or without G add-on)
fbq(‘trackCustom’, ‘SamplePurchase’, {
currency: currency,
value: orderValue,
content_name: “Sample Purchase”,
content_ids: sampleProductIDs,
content_type: “product”
});
}
});