How can I retrieve the Shop_id from a web_pixel event?

Topic summary

Main issue: retrieving shop information (e.g., shop_id or .myshopify domain) from a custom Shopify Web Pixel on checkout_completed.

Key methods:

  • Pixel settings: Define a field in extension.toml (e.g., settings.fields.shopID) and set it via webPixelCreate. Access it inside the pixel via the settings parameter (settings.shopID).
  • Init data: Read the .myshopify domain from init?.data?.shop?.myshopifyDomain within the pixel script.

Clarifications:

  • The shop object is available on init.data, not event.data. Inspecting event.data will not show shop details.

Outcomes:

  • Retrieving the .myshopify domain via init.data is confirmed to work.
  • No direct method for a numeric shop_id via the event was provided; using settings to pass/store it is the suggested workaround.

Artifacts:

  • Code snippets are central (extension.toml field, webPixelCreate settings, and init.data usage). Screenshots were used to illustrate object structure.

Status:

  • Resolved with practical approaches; no remaining open questions noted.
Summarized with AI on December 20. AI used: gpt-5.

I think you checked event.data, not init.data.