Meta Analytics
Meta Analytics
If you want to correctly track AddToCarts within your meta pixel, you have to listen to the Smootify Add To Cart event and send the event using the fbq
utility of Meta, as example you can use the snippet below:
document.addEventListener('smootify:added_to_cart', (event) => {
const {lines, cart, goToCheckout} = event.detail;
if (window.fbq) { for (let line of lines) { const cartLine = cart.lines.nodes.find(e => e.merchandise.id == line.merchandiseId); if (cartLine) { fbq('track', 'AddToCart', { content_type: "product", contents: [{ id: line.merchandiseId.split("/").pop(), quantity: line.quantity, value: Number(cartLine.cost.totalAmount.amount), currency: cartLine.cost.totalAmount.currencyCode }] }) } } }})
This is the correct way to track the add to cart, since a click on the button will not ensure you that the product is purchasable or not.
Naturally, be sure you have the consent to track!