Nowadays, almost all online stores use Facebook ads to reach customers and grow, so it’s crucial to make sure the data that your shop sends to Facebook via the FB Pixel is accuarate, as otherwise you would most likely be loosing money by not having your ad campaigns optimized correctly.
If you have issues on your Shopify store where the Facebook “AddToCart” event fires twice, this is very likely caused by the jQuery’s .on method.
Using the “.on” method with a descendant selector in any of the theme files usually causes Trekkie (Shopify’s web analytics app) to fire two AddToCart events.
Fires Two Facebook “AddToCart” events:
$('body').on('submit', 'form', function(e) {
// ..custom code
})
Works as expected:
$('form').on('submit', function(e) {
// ..custom code
})
In many cases, resolving this issue takes some time and patience, as you first have to find the relevant .on() function in your theme code that is causing the error. Remember that there might be more than one instance that you will have to modify. Please note the code snippets above use generic selectors to illustrate the issue. Make sure you adjust the selectors accordingly when updating your theme code.