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 updatingdocument.title. - environment —
prodfor live data,devfor testing. Events sent withdevare logged but not processed.
Complete Reference
context object
url string required-if-applicable
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"
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
Type of page (product, home ...)
page_type: "product"
page_title string optional
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
Allowed values: prod, dev
environment: "prod"
Examples
- Standard Website
- SPA Application
- Development
{
"page_type": "product",
"environment": "prod"
}
URL is collected automatically. Only page_type and environment need to be specified.
{
"url": "https://example.com/dashboard/analytics?date_range=30d",
"page_type": "dashboard",
"page_title": "Analytics | Example App",
"environment": "prod"
}
For SPA applications, url must be provided manually on each route change since the browser URL doesn't update automatically. Send page_title too when your router fires before the new title is set.
{
"page_type": "product",
"environment": "dev"
}
Events with dev environment are logged for debugging but not processed or forwarded to destinations.
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_typeacross your site - SPA route tracking — ensure context updates on every significant route change, including
page_titlewhen the title changes after the push - Use
devfor testing — setenvironmenttodevduring integration to validate events without processing - URL sensitivity — be mindful of sensitive information in URL parameters (session tokens, personal identifiers); consider filtering before tracking