Skip to content

Commit 24ebb20

Browse files
authored
Document analytics labels for enrichment module (#6337)
1 parent 2591691 commit 24ebb20

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

dev-docs/integrate-with-the-prebid-analytics-api.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ For instructions on integrating an analytics provider, see the next section.
3737

3838
![Prebid Analytics Architecture Diagram]({{ site.baseurl }}/assets/images/prebid-analytics-architecture.png){: .pb-md-img :}
3939

40+
## Analytics Labels
41+
42+
Prebid events can carry an object of **analytics labels** that annotate the payload with experiment, rollout, or troubleshooting context. Labels are available to every analytics adapter in two places:
43+
44+
* as a top-level `labels` object that combines every active label
45+
* as `args.analyticsLabels` inside the event payload so adapters that only inspect the args can still read them
46+
47+
Publishers can declare their own labels with standard configuration:
48+
49+
```javascript
50+
pbjs.setConfig({
51+
analyticsLabels: {
52+
experiment_1: 'group_a',
53+
releaseTrain: 'B'
54+
}
55+
});
56+
```
57+
58+
Modules can also contribute labels by calling `setLabels` from `AnalyticsAdapter`. One example is the [Enrichment Lift Measurement Module](/dev-docs/modules/enrichmentLiftMeasurement.html), which attaches the active A/B test configuration so analytics adapters can report on each test run. All labels defined by publishers or modules are merged together before being delivered to analytics adapters.
59+
60+
Analytics adapters that want to use this metadata simply read either `event.labels` or `event.args.analyticsLabels` in their `track` implementation.
61+
4062
## Creating an Analytics Module
4163

4264
Working with any Prebid project requires using Github. In general, we recommend the same basic workflow for any project:

dev-docs/modules/enrichmentLiftMeasurement.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pbjs.setConfig({
5656
});
5757
```
5858

59-
The following object will be attached to analytics labels based on the configuration above:
59+
The following object will be attached to [analytics labels](/dev-docs/integrate-with-the-prebid-analytics-api.html#analytics-labels) based on the configuration above:
6060

6161
```javascript
6262
{
@@ -65,3 +65,14 @@ The following object will be attached to analytics labels based on the configura
6565
{ name: '33acrossIdSystem', percentage: 0.5, enabled: false } // May be true or false depending on random selection
6666
]
6767
}
68+
```
69+
70+
### Analytics Labels
71+
72+
The module adds one analytics label whose key matches the configured `testRun` value. The value is an array that lists every User ID submodule participating in the experiment along with its configured percentage and whether it was enabled for the current page view. Analytics adapters can use that label to segment reporting by experiment group.
73+
74+
- `name`: The User ID submodule name.
75+
- `percentage`: The configured rollout percentage, which is useful for validating traffic splits.
76+
- `enabled`: Indicates whether the submodule ran for the current user; this is the randomized value that identifies the treatment/control groups.
77+
78+
See the [Analytics labels](/dev-docs/integrate-with-the-prebid-analytics-api.html#analytics-labels) section for guidance on how analytics adapters consume this metadata.

0 commit comments

Comments
 (0)