Open rplakas opened 1 year ago
I figured out to do this with Individual Buy Buttons, still don't have it working with Collection Code though.
Here it is in case someone else needs it:
`"DOMEvents": { 'click .shopify-buybtn-wrapper .shopify-buybtn': function (evt, target) {
var prod_name = ui.components.product[0].model.title;
var prod_qty = ui.components.product[0].selectedQuantity;
var prod_sku = ui.components.product[0].selectedVariant.sku;
var prod_price = ui.components.product[0].selectedVariant.price.amount;
fbq('track', 'AddToCart', {
content_name: prod_name,
content_id: prod_sku,
quantity: prod_qty,
content_type: 'product',
value: prod_price,
currency: 'USD'
});`
For whatever reason using
var prod_sku = ui.components.product[0].selectedVariant.title;
resulted in it passing "Default Title" instead of the actual product title.
Does anyone know how to get this to work for Collection Code?
Using var prod_sku = ui.components.collectiont[0].selectedVariant.sku
results in an error in the console
Does anyone know if its possible to pass the Product Name, SKU and Price to Meta Pixel to the Meta Pixel and GTM/GA4?
Where would I find the variable names? Here is my add-to-cart tracking code within the Buy Button.