Shopify Meta pixel 未被偵測到?重新安裝前先檢查 frame
Shopify Meta pixel not detected? Check the frame before reinstalling it
Shopify 商品頁即使頂層 frame 沒有 fbq 函數,仍可能發出 Meta pixel 請求;排查時先確認請求來自哪個 frame,避免重複安裝。瀏覽器測試顯示,偵測不到事件可能是工具查看了錯誤的 JavaScript context,或整合尚未載入完成。PixelScope 可在 Chrome 本機顯示觀察到的瀏覽器端事件,並標示值得調查的細節。
A Shopify product page can make a Meta pixel request even when the top frame has no fbq function. I reproduced that discrepancy in a small browser test. If you're debugging a store, the distinction can save you from installing a second copy of the pixel.
The browser test
The test served a synthetic shop page with one sandboxed iframe. Its script initiated a Meta AddToCart image request with a test pixel ID and a value of 9 USD. Playwright intercepted the request locally. PixelScope reported the event and attributed it to a frame other than the top frame. A separate test injected a ViewContent request after a 1.2-second delay, and PixelScope captured that too.
This isolates two separate reasons for an empty debugger view. A tool can be looking in the wrong JavaScript context, or you can look before the integration has finished loading. The synthetic test covers iframe visibility and delayed requests. Shopify's web pixel implementations have two distinct environments. Custom pixels use a lax sandbox, and app web pixels use a strict sandbox based on web workers. Shopify Web Pixels documentation.
How to check your own implementation
- Open Chrome DevTools before loading a product page. In Network, enable Preserve log so you can see requests across navigation.
- On a store you manage, choose the consent state you want to test. Record whether you interacted with the banner and give the page time to initialize.
- Filter for
facebook.com/tr. Click Add to cart once, then check the request's event name, pixel ID, value, currency and event ID where present. Keep the timestamp and initiator if the event is missing or appears twice. - Check the integration in Shopify Customer events and use Events Manager or your own server logs to verify platform receipt and browser/server deduplication. A browser capture shows the browser side of the flow.
- If two requests share an event name, compare their pixel and event IDs first. Review Customer events, the theme, and any tag manager or app configuration before removing a tag.
For a quicker view, PixelScope on the Chrome Web Store shows observed browser-side events and flags details worth investigating. It's free and runs locally in Chrome.
Disclosure: I develop PixelScope. This article was drafted with AI assistance using results from the project's browser test.
來源:DEV Community · dev.to