Clear History

Adding Context

Whilst the tracking set-up provides event data on user actions at a specific point in time, context describes the setting in which an event takes place. To describe the context of an event, we need to define and capture individual entities. For example:

  • The user performing an action
  • The web page the action occurred on
  • A product that has been interacted with

Together, these entities make up the context of an event.

Similar to the predefined events, a number of entities are available to implement out of the box including:

  • webPage Entity - Adds the Pageview ID
  • session Entity - Information about the user session
  • performanceTiming Entity - Calculate page performance metrics
  • geolocation Entity - Information on the users location

Step 1: Enable predefined entities

The webPage entity is enabled by default in the JavaScript tracker. This is required for modelling your data using the dbt-web-model.

Enable the context by including the below context options in your tracker creation.

window.snowplow('newTracker', 'sp', '{{Url for Collector}}', {
  ...
  contexts: {
        webPage: true,
      }
  ...
});

Each event sent with this tracker will now contain the data from each of these entities.

Step 1: Enable predefined entities

The webPage entity is enabled by default in the JavaScript tracker. This is required for modeling your data using the dbt-web-model.

Enable the context by including the below context options in your tracker creation.

let tracker = newTracker('sp', '{{Url for Collector}}', {
  ...
  contexts: {
    webPage: true
  }
  ...
});

Each event sent with this tracker will now contain the data from each of these entities.

Step 1: Enable predefined entities

The webPage entity is enabled by default in the JavaScript tracker. This is required for modelling your data using the dbt-web-model.

Enable the context by including the below context options in your tracker creation.

export class SnowplowService {
  tracker: BrowserTracker = newTracker('sp', '{{Url for Collector}}', {
  ...
  contexts: {
      webPage: true,
      session: false
      }
  ...
  }
});

Each event sent with this tracker will now contain the data from each of these entities.

Step 1: Enable predefined entities

The webPage entity is enabled by default in GTM. This is required for modeling your data using the dbt-web-model.

Enable the context by including the below context options in your variable template editor, under predefined contexts.

Webpage Context

Each event sent with this tracker will now contain the data from each of these entities.