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.
  • environmentprod 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://shop.example.com/products/laptop?color=silver&storage=512gb&utm_source=google"
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"

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",
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
  • 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