Skip to main content

Tracking Events

Snowplow has been built to enable you to track a wide range of events that occur when users interact with your apps.

We provide several built-in methods to help you track different kinds of events. The methods range from single purpose methods, such as screenView, to the more complex but flexible selfDescribing, which can be used to track any kind of user behavior. We strongly recommend using selfDescribing for your tracking, as it allows you to design custom event types to match your business requirements. This post on our blog, "Re-thinking the structure of event data" might be informative here.

Tracking methods supported by the Roku Tracker:

MethodEvent type tracked
selfDescribingCustom event based on "self-describing" JSON schema
structuredSemi-custom structured event
screenViewView of screen

All the methods share common features and parameters. Every type of event can have an optional context added. A Timestamp can also be provided for all event types to override the default event timestamp. See the next page to learn about adding extra data to events. It's important to understand how event context works, as it is one of the most powerful Snowplow features. Adding event context is a way to add depth, richness and value to all of your events.

Snowplow events are all processed into the same format, regardless of the event type (and regardless of the tracker language used). Read about the different properties and fields of events in the Snowplow Tracker Protocol.

We will first discuss the custom event tracking methods, followed by the out-of-the-box event types. Note that you can also design and create your own page view, or screen view, using selfDescribing, to fit your business needs better. The out-of-the-box event types are provided so you can get started with generating event data quickly.

Track self-describing events with selfDescribing

Use selfDescribing to track a custom event. This is the most advanced and powerful tracking method, which requires a certain amount of planning and infrastructure.

Self-describing events are based around "self-describing" (self-referential) JSONs, which are a specific kind of JSON schema. A unique schema can be designed for each type of event that you want to track. This allows you to track the specific things that are important to you, in a way that is defined by you.

This is particularly useful when:

  • You want to track event types which are proprietary/specific to your business
  • You want to track events which have unpredictable or frequently changing properties

A self-describing JSON has two keys, schema and data. The schema value should point to a valid self-describing JSON schema. They are called self-describing because the schema will specify the fields allowed in the data value. Read more about how schemas are used with Snowplow here.

After events have been collected by the event collector, they are validated to ensure that the properties match the self-describing JSONs. Mistakes (e.g. extra fields, or incorrect types) will result in events being processed as Bad Events. This means that only high-quality, valid events arrive in your data storage or real-time stream.

note

Your schemas must be accessible to your pipeline to allow this validation. See Managing data structures for information on how to create and update schemas.

The selfDescribing method takes a roAssociativeArray. This array takes a schema name and a flat hash of event data.

Example (assumes that you mounted the Snowplow instance in m.global.snowplow):

m.global.snowplow.selfDescribing = {
data: {
saveId: "4321",
level: 23,
difficultyLevel: "HARD",
dlContent: true
},
schema: "iglu:com.example_company/save_game/jsonschema/1-0-2"
}

Track structured events with structured

This method provides a halfway-house between tracking fully user-defined self-describing events and out-of-the box predefined events. This event type can be used to track many types of user activity, as it is somewhat customizable. "Struct" events closely mirror the structure of Google Analytics events, with "category" (se_ca), "action" (se_ac), "label" (se_la), and "value" (se_va) properties.

As these fields are fairly arbitrary, we recommend following the advice in this table how to define structured events. It's important to be consistent throughout the business about how each field is used.

ArgumentDescriptionRequired in event?
se_caThe grouping of structured events which this action belongs toYes
se_acDefines the type of user interaction which this event involvesYes
se_laOften used to refer to the 'object' the action is performed onNo
se_prDescribing the 'object', or the action performed on itNo
se_vaProvides numerical data about the eventNo

Example:

m.global.snowplow.structured = {
se_ca: "shop",
se_ac: "add-to-basket",
se_pr: "pcs",
se_va: 2
}

Track screen views with screenView

Use screenView to track a user viewing a screen (or similar) within your app. This is the page view equivalent for apps that are not webpages. The arguments are nameidtype, and transitionType; while all are optional, you must provided at least one of either name or id to create a valid event. "Name" is the human-readable screen name, and "ID" should be the unique screen ID.

This method creates an unstruct event, by creating and tracking a self-describing event. The schema ID for this is "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0", and the data field will contain the parameters which you provide. That schema is hosted on the schema repository Iglu Central, and so will always be available to your pipeline.

Example:

m.global.snowplow.screenView = {
id: "screen23",
name: "HUD > Save Game"
}
Was this page helpful?