Hello. I’m trying to get a post-purchase pixel working to track purchase events using the Twitter Pixel. I’ve added the following script to the post-purchase script section in Shopify (we have not upgraded to checkout extensibility).
Am I approaching this the right way? I know there is a customer events section in Shopify for custom pixels, but I have not dove into that.
In addition, I’ve attempted to add the pixel tracking via Shopify’s custom pixels, and it works for my add to cart event, but not my purchase events.
// Step 1. Initialize the JavaScript pixel SDK (make sure to exclude HTML)
!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);
},s.version='1.1',s.queue=[]);var f=t.createElement(n),h=t.getElementsByTagName(n)[0];
f.async=!0,f.src='https://static.ads-twitter.com/uwt.js',h.parentNode.insertBefore(f,h)}(window,document,'script');
twq('init','[base-pixel-redacted]'); // Initialize Twitter Pixel with your base pixel ID
// Step 2. Subscribe to customer events with analytics.subscribe(), and add tracking
// Track Cart Additions
analytics.subscribe("cart_addition", event => {
twq('track','[cart-id-redacted]', {
content_ids: event.data.product_ids,
content_type: 'product',
value: event.data.total_price,
currency: 'USD'
});
});
// Track Purchases
analytics.subscribe("checkout_completed", event => {
twq('track','[purchase-id-redacted]', {
value: event.data.checkout.totalPrice.amount,
currency: event.data.checkout.currencyCode,
email_address: event.data.checkout.email
});
});
Hello!
Did you find the solution? I have the same issue!
Thanks a lot,
Letty
Have you had any luck? Suck as well
I have the same issue, I contacted shopify team and nobody tell us how to fire the X pixel. This request have 2,041 Views, and still no help from Shopify…