Skip to content

The window.sophi_object layer

The global window.sophi_object follows the SophiObjectShape: a config block, an optional event-type override, and optional context objects for the current page.

Shape

Conceptually:

interface SophiObjectShape {
  config?: SophiConfig;
  event_type?: ExternalEventType;
  page?: PageObject;
  user?: UserObject;
  product?: ProductObject;
  basket?: BasketObject;
  listing?: ListingObject;
  transaction?: TransactionObject;
}

Full field definitions: Types reference.

Watched keys (Proxy)

After startup, window.sophi_object is wrapped so that assignments to these keys trigger event processing (build payload → queue for send):

  • page
  • user
  • product
  • basket
  • listing
  • transaction

Not watched (no collection on write):

  • config
  • event_type

Values are written to the object before events are derived, so each send reflects the latest state.

Default event_type per key

When event_type is not set on sophi_object for that update, the SDK uses:

Key assigned Default event_type
page page_view
user identify
product product_view
basket basket_view
listing listing_view
transaction purchase

Override by setting sophi_object.event_type before the assignment that triggers collection, or by passing event_type in SophiTracker.push().

Initial page load

If you set multiple objects on sophi_object before the script loads, startup processing runs once per present watched key, so you may get several events (each may use the same or different resolved event_type depending on overrides).

page is required for events

The SDK builds each event from the current sophi_object. page must be present (with valid type and url) for events to be sent; otherwise that update produces no event.