I’m trying to fire a custom facebook event on the order confirmation page using the additional script in checkout settings.
Here is the script I’m using:
For some reason the additional scripts fire before the facebook pixel does resulting in: Uncaught ReferenceError: fbq is not defined
I could insert the pixel code in the additional scripts section before my custom script but that means there are two pixels firing on the page and that’s not optimal.
Facebook is currently implemented using Shopify’s own FB app
Hi @Trulyag ,
I’m sorry to hear you are having issues with Facebook tracking.
If you have confirmed the Facebook pixel is installed after additional scripts are run, a good solution would be to wait until the DOM is ready before firing off tracking events. That will give the browser time to finish installing the Facebook pixel.
var ready = (callback) => {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
}
ready(() => {
// Insert the tracking JS code here
});
Hope that helps,
Ian