For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
Shopify has recently mandated that pixel apps use the new Web Pixel App Extension, which has some notable shortcomings. The Shopify Web Pixel operates within a strict sandbox environment, meaning it does not have access to the global window and document objects.
This presents a challenge for pixels like Facebook and TikTok, which require their base code to be loaded. These libraries need access to the global window and document objects to function correctly. Unfortunately, this does not appear to be possible within the strict sandbox environment enforced by Shopify.
Facebook base code example
!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');
From this above code we get window is not defined in strict sandbox environment.
I have same issue for GTM. Is there any update?
No reply yet from anyone.
I'm having the same issue when applying the Meta pixel base code from Facebook to web pixel shopify. The issue is that shopify web pixel is running on strict environment so that we couldn't define fbq function to the web pixel.
If anyone has the solution it will be great!
The solution I found is to avoid using pixel-based libraries and instead directly call tracking APIs with the appropriate parameters. You can view the details of these API requests in the Network tab of your browser's developer tools.