Metrics Platform/Web schema
This page documents Metrics Platform's base schema for web. The schema includes three types of properties:
- core properties: fields describing the event itself
- interaction data: fields with custom values set by the instrument code to fit the needs of the experiment
- contextual attributes: fields describing the performer and environment of the event
This page helps you understand which properties of each type are available, so you can plan your instrumentation specification. For property descriptions and types, see the web base schema definition.
Example event
Example event |
---|
[
{
"action": "impression",
"action_source": "community-updates",
"action_context": "mwomen_in_red",
"agent": {
"client_platform": "mediawiki_js",
"client_platform_family": "desktop_browser",
"release_status": null
},
"dt": "2024-10-01T13:18:42.672Z",
"experiments": {
"assigned": {
"growth-experiments": "control"
},
"enrolled": [
"growth-experiments"
]
},
"http": {
"has_cookies": null,
"method": null,
"protocol": null,
"request_headers": {
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
},
"response_headers": null,
"status_code": null
},
"mediawiki": {
"database": "testwiki",
"site_content_language": "en",
"site_content_language_variant": null,
"skin": null,
"version": null
},
"meta": {
"domain": "test.wikipedia.org",
"dt": "2024-10-01T13:18:46.060Z",
"id": "1f5c1542-c60d-4edb-90a3-89c1904b71d1",
"request_id": "28ac4e36-d667-462b-bd1e-34268bebd856",
"stream": "mediawiki.product_metrics.homepage_module_interaction",
"uri": null
},
"page": {
"title": null,
"content_language": "en",
"id": null,
"is_redirect": null,
"namespace_id": null,
"namespace_name": null,
"revision_id": null,
"user_groups_allowed_to_edit": null,
"user_groups_allowed_to_move": null,
"wikidata_qid": null
},
"performer": {
"active_browsing_session_token": "74904276fea622b14739",
"can_probably_edit_page": null,
"edit_count": null,
"edit_count_bucket": "100-999 edits",
"groups": [
"sysop",
"*",
"user",
"autoconfirmed"
],
"id": null,
"is_bot": false,
"is_logged_in": true,
"is_temp": false,
"language": "en",
"language_variant": null,
"name": "Martin Urbanec (WMF)",
"pageview_id": "b60bbc9b8c4985d4f8b6",
"registration_dt": "2019-06-28T20:57:21.000Z",
"session_id": "0212f2552cd8118d4811"
},
"sample": {
"rate": 1,
"unit": "pageview"
},
"$schema": "/analytics/product_metrics/web/base/1.3.0"
}
]
|
Core properties
These properties are added automatically to every event.
$schema
dt
meta.stream
meta.domain
meta.id
meta.dt
meta.request_id
Instrument and experiment management
In addition, some core properties are added to events by the client to aid in instrument and experiment management. These properties are set automatically and cannot be customized. They include:
JavaScript:
experiments
assigned
enrolled
instrument_name
PHP: Unsupported
Interaction data
Metrics Platform supports interaction data that you can customize to fit the needs of your instrument. You can set these properties to any meaningful value to provide the data required for your event. See the API docs for information about how to set these properties when submitting events.
action
(required)- Examples: "click", "type", "scroll"
action_subtype
- Examples: "submit" or "cancel" for click actions; "up" or "down" for scroll actions
action_context
- Examples:
{"stay_logged_in":true}
(for click events on login button) action_source
- Examples: "sidebar"
element_friendly_name
- Analyst-friendly name of the UI element interacted with. For example: "Donate"
element_id
- ID of the UI element interacted with
funnel_entry_token
- A randomly generated identifier for linking multiple events belonging to a (work)flow. A single session (identified by
performer.session_id
may have multiple pageviews (identified byperformer.pageview_id
) which may have multiple instances offunnel_name
that are separately identified by this token. funnel_name
- Analyst-friendly name such as "emergency-flow" or "Add a Link suggestion"
Managed data
These properties are not manually set by your instrument but are instead managed by the client libraries.
funnel_event_sequence_position
- 0 for the first event submitted by instrument, incremented by 1 for each subsequent event
Contextual attributes
Contextual attributes provide information about the performer who triggered the event and the wiki where the event occurred. The values of contextual attributes are populated automatically by Metrics Platform when the event is generated.
While each client includes a few contextual attributes automatically, most attributes must be enabled in the instrument's event stream configuration. For more information, see Contextual attributes.
Supported contextual attributes for JavaScript |
---|
The JavaScript client supports these contextual attributes:[1] Included automatically:[2]
Optional:
|
Supported contextual attributes for PHP |
---|
The PHP client supports these contextual attributes:[3] Included automatically:[4]
Optional:
|
Code references
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/js/src/ContextUtils.js
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/js/src/ContextController.js
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/php/src/StreamConfig/StreamConfig.php
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/php/src/ContextController.php