Window.ShopifyAnalytics in sandbox iframe

Topic summary

A developer is attempting to track page types (checkout and thank you pages) using window.ShopifyAnalytics within Shopify’s sandbox iframe for web pixels.

Core Issue:

  • The proposed code relies on accessing window.ShopifyAnalytics.meta to determine page type
  • No official documentation confirms whether this global object is available in the sandbox environment

Key Finding:

  • The window element is not accessible within Shopify’s Pixel API sandbox environment
  • This means the proposed tracking code will not function as intended

Current Status:

  • The original approach is confirmed non-viable
  • The developer is seeking alternative methods to track page types in sandbox environments
  • The question of how to properly implement page type tracking in Shopify’s sandboxed pixels remains unanswered
Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

We have been trying to setup a function such as below on a Sandbox pixel page that tracks Checkout and thank you. There is no one publicly available link that states that clearly and I just wanted to know for a Checkout and thank you Sandbox will this work?

function(){
var meta = window.ShopifyAnalytics && ShopifyAnalytics.meta;
if (meta && meta.page && meta.page.pageType) {
  return meta.page.pageType;
}
var path = window.location.pathname || '';
if (path.indexOf('/checkouts/') === 0) {
  return path.indexOf('/thank-you') > -1 ? 'thank_you' : 'checkout';
}
return 'storefront';
}

There is no single publicly available link that explicitly states:

“Inside Shopify’s sandbox iframe for web pixels, the global window.ShopifyAnalytics and its property ShopifyAnalytics.meta are available.”

If you are referring to sandbox in Pixels API, the window element is not available in sandbox environment so you cannot use this code,

So What would be a better way to Track Sandboxes Page type in Shopify
I did run a sample JS and gave me this
So this wont happen inside a Sandbox Thank you or checkout page ?