magento2 – How can I track Add To Cart values using Facebook Pixel custom pixel for Magento 2 without plugins?


I would appreciate any help with setting up a custom Facebook Pixel for Magento which tracks the values for when customers add products to their cart. My store requires for the swatch option to be selected before a product can be successfully added to the cart (eg click/select your size before clicking on add to cart).

Does anyone have an idea on how I can track the value of the swatch options and pass them into my Facebook pixel? I am using the custom pixel option:

<!-- Facebook Pixel Code -->

!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=();t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)(0);
s.parentNode.insertBefore(t,s)}(window,document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘1234567890’);
fbq(‘track’, ‘AddToCart’, {
content_type: ‘product’
});
fbq(‘trackCustom’, {content_name: ‘{{Click Text}}’});

Any tips or advice would be appreciated, thanks.