window.ShopifyAnalytics.meta missing/empty inside Theme Editor? (Works fine on Live storefront)

Hi everyone,

I’m experiencing a strange issue with the global window.ShopifyAnalytics object, specifically inside the Theme Editor (Customizer) environment.

The Problem: When inspecting the live storefront (production), window.ShopifyAnalytics.meta contains all the expected data (such as product.id, page, currency, etc.). However, when I open the Theme Editor / Preview, the meta object or the properties inside it return undefined.

This is causing some of our custom features/scripts to break during the merchant’s customization process because our code relies on pulling the current Product ID or Page Type from that object.

Steps to reproduce:

  1. Open the Theme Editor for any theme.

  2. Open Browser DevTools (F12) → Console (select the iframe section).

  3. Type window.ShopifyAnalytics.meta.

  4. Result: It returns undefined, whereas doing the exact same thing on the live store returns the full metadata.

My questions:

  1. Did Shopify recently push an unannounced update that strips or restricts the ShopifyAnalytics internal object inside the Theme Editor iframe for performance/security reasons (like CSP or preventing data pollution)?

  2. If this is an intended behavioral change, what is the officially recommended way to fetch current page/product metadata globally in JavaScript that works seamlessly in both the Live Storefront and the Theme Editor? (Should we fully migrate to window.Shopify or parse via Liquid?)

Thanks in advance.

@Dev_369 , This seems to be an intentional behavior in the theme editor, so it is safer to rely on liquid rendered data or window.shopify rather than window.ShopifyAnalytics.meta for theme compatible scripts

My app was using window.ShopifyAnalytics.meta normally, but only 3-4 days lately, it suddenly didn’t work. Most of the features are using window.ShopifyAnalytics.meta.page.pageType, the issue doesn’t happen on live, but theme editor

Okay,
Thanks for the clarification. If it was working normally until 3–4 days ago and the issue only occurs in the Theme Editor (not on the live storefront), it may be related to a recent Shopify change in the Theme Editor environment. Are you seeing “window.ShopifyAnalytics.meta” as “undefined”, or is it only “meta.page.pageType” that’s missing?

Thanks for your quick response,

I’m seeing “window.ShopifyAnalytics.meta” as “undefined”

Thanks for the quick response.

If “window.ShopifyAnalytics.meta” is “undefined” only in the Theme Editor but works correctly on the live storefront, it sounds like this may be related to a recent change in Shopify’s preview environment rather than your implementation.

This can be fixed, but it requires a careful audit to maximize errors.
If you like I can preview it and let you know how this could be done.
And please feel free to share any other concerns you may be facing on your website.

Is there any temporary workaround solution? For now, I need to get the product.id and page.pageType from meta

As a temporary workaround, you can avoid relying on “window.ShopifyAnalytics.meta” in the Theme Editor. For example, you can retrieve the current page type from the URL or the DOM, and get the product ID from Liquid (if it’s available on the page) or by using Shopify’s product JSON endpoints. This can help keep your app functional until the underlying issue with “window.ShopifyAnalytics.meta” is resolved.

But it have to be previewed first before proceeding.