Skip to main content

Context Web Object

Overview​

The context web object captures browser environment data for events collected through JavaScript implementations. Most context data (URL, environment) is collected automatically by the DATA Reshape script. Manual implementation is only needed for SPA applications or when you want to specify page_type for more granular analytics.

Properties​

  • url — collected automatically for standard websites. Required only for SPA applications where URL changes don't trigger automatic page context updates.
  • page_type — categorizes the current page for analytics (e.g. product, category, cart, checkout, home, blog, contact). Free-form string, use consistent naming across your site.
  • page_title — title of the current page. Collected automatically from document.title. Required only for SPA applications that push the event before updating document.title.
  • environment — prod for live data, dev for testing. Events sent with dev are logged but not processed.

Complete Reference​

context object

url string required-if-applicable

info

Collected automatically for standard websites. Required only for SPA applications where URL changes don't trigger automatic page context updates.

url:"https://example.com/products/prod_abc123?utm_source=example"
warning

URL Parameter Sensitivity: Be mindful of sensitive information in URLs. Query parameters may contain personal identifiers, session tokens, or private information that should be handled according to privacy regulations.

page_type string recommended

info

Type of page (product, home ...)

page_type: "product"

page_title string optional

info

Title of the current page. Collected automatically from document.title when missing. Send it on SPA route changes when the event is pushed before your framework updates document.title, otherwise the event carries the title of the previous route.

page_title: "Sony RM-IP500 Remote Control | Example Store"

environment string recommended

info

Allowed values: prod, dev

environment: "prod"

Examples​

{
"page_type": "product",
"environment": "prod"
}

URL is collected automatically. Only page_type and environment need to be specified.

SPA Implementation​

For Single Page Applications, push a new event with updated context on each route change:

// On each SPA route change, push a new event with the current route URL
window.reshape = window.reshape || [];
reshape.push({
event: {
name: "page_viewed"
},
context: {
url: currentRouteUrl, // Current route URL from your framework's router
page_type: "dashboard",
page_title: currentRouteTitle, // Title of the new route, if document.title is not updated yet
environment: "prod"
}
});

Best Practices​

  • Consistent page types — use a standardized naming convention for page_type across your site
  • SPA route tracking — ensure context updates on every significant route change, including page_title when the title changes after the push
  • Use dev for testing — set environment to dev during integration to validate events without processing
  • URL sensitivity — be mindful of sensitive information in URL parameters (session tokens, personal identifiers); consider filtering before tracking