How can I manually set up Meta pixel tracking for specific actions on my platform?

Olegs30
Shopify Partner
1 0 0

Hi Shopify community I have couple of questions about manually setup the pixel code of Meta to track different actions on the platform, I use Conversions Gateway connected to my events Manager by stape.

 

So firstly I want to track the Add to cart button which is located on the product pages, where is the description and etc, after people view the product. So I found out there is a possibility to track button if you find exact code, id, or any parameter you can find your button in code. So I used inspect tool found it on my website:

 

Olegs30_0-1684963361552.png

And then I also have found it in the product page code:

Olegs30_1-1684963415504.png

 

So the first question - I do not understand where exactly the code should be placed for it to trigger right way I have this code for that: *and secondly I need to put the basic pixel code above all this? or I can somehow reference this to the pixel code I have in theme.liquid file? 

 

<script type="text/javascript">
  var button = document.getElementById('addToCartButton');  button.addEventListener(
    'click', 
    function() { 
      fbq('track', 'AddToCart', {        content_name: 'Really Fast Running Shoes', 
        content_category: 'Apparel & Accessories > Shoes',        content_ids: ['1234'],        content_type: 'product',        value: 4.99,        currency: 'USD' 
      });          
    },
    false
  );
</script>

Or I found also this basic code, or it won't work if I will put it right in the product theme in button code? 

onclick=fbq('track', 'AddToCart', { content_category: 'Apparel & Accessories > Shoes', content_ids: ['1234'], content_type: 'product',

 

2. The same question is about the Intiate checkout button it's on the side sliding add to cart, and would I need to do same with that button?

 

And 3. question at the moment I have 2 add to carts one sliding from side, and second is on collections page where you can add to cart without viewing product - and I want to remove second option add to cart, when they can add it without looking into product view, how it could be done?

 

For reference I will add up : My store - if it helps to give the answer.

 

Thanks and have a great day!

 

Replies 0 (0)