Magento 2 - Facebook pixel tracking on AddToCart event
-
01-03-2021 - |
質問
Note: Before marking it as duplicate please read description carefully
I am creating a module for Facebook pixel tracking and I am stuck at AddToCart
event.
I have seen some 3rd party extensions, but the issue is they are tracking AddToCart
after page load and my AddToCart
event should based on ajax based.
So my question is, how can I trigger AddToCart
facebook pixel code after ajax add to cart?
解決
If you know the ID/Class of the add to cart button why not just create a custom on page javascript something like
$('.addtocart.btn').on('click', function()
{
// Do the Magic
});
you may need to adjust the class. i will create a extension for FB pixel very soon to include the ajax add to cart option. so fixes an issue a lot of people will be having