0

We currently using GTM for all our tracking codes.

To setup Facebook Dynamic ads and Facebook pixel, I need to collect events like AddToCart, Purchase etc.

<script> fbq('track', 'Purchase', { content_ids: ['1234', '4642', '35838'], content_type: 'product' value: 247.35, currency: 'USD' }); </script> 

How to get Magento's SKUs and Cart value and pass to Facebook tracking code using Google Tag Manager?

1 Answer 1

0

The best way to go about this is a combination of datalayer variables and one custom html tag. when the user clicks on the purchase button you push an event to the datalayer that has the information you need to pass along to facebook. something like datalayer.push({ event:'PURCHASE_BUTTON_CLICKED', PURCHASE_BUTTON_CLICKED: { ids:['1234', '4642', '35838'], type:'product, value: getTotalValue(), currency: 'USD' }) then inside GTM use one or several (i recommend several) different datalayer variables referencing different attributes of this datalayer object. you can use these variables in your custom html tag by wrapping them in double curly braces as shown in the image. all that is left is to add a trigger to the custom html tag.

try and feed as much as you can into the datalayer and gtm so that you can reuse all these variables to send off any number of tags.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.