Skip to content

Commit d2821f5

Browse files
committed
Added new recipe for visit tracking
1 parent 5b16945 commit d2821f5

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed
34.6 KB
Loading
24.5 KB
Loading

learn/recipes/pageview-tracking.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Tracking Pageviews using raw Telemetry Data
2+
3+
Telemetry events with eid `IMPRESSION` can be used to create a time-series pageview graph. [Impression events](http://docs.sunbird.org/latest/developer-docs/telemetry/specification/#impression) are generated when a user visits any page. Impression events look like the one below
4+
5+
```JSON
6+
{
7+
"eid": "IMPRESSION",
8+
"ets": 1664162202978,
9+
"ver": "3.0",
10+
"mid": "LOAD_TEST_6c029add-7508-43c4-aefc-9591cb53e5f9",
11+
"actor": {
12+
"id": "7ec05264-b111-4833-9594-55d807c44084",
13+
"type": "User"
14+
},
15+
"context": {
16+
"channel": "99fbe3f8-c07a-4ace-b0ac-f2fa7411da07",
17+
"pdata": {
18+
"id": "sunbird.app",
19+
"pid": "sunbird-portal.collectioneditor",
20+
"ver": "1"
21+
},
22+
"env": "user",
23+
"sid": "74489131-fdbb-448c-b36b-98fe8c70971b",
24+
"did": "7b238a24-bc15-487d-8a59-b4ad9f37d178",
25+
"cdata": [],
26+
"rollup": {
27+
"l1": "do_21271780182595993616932",
28+
"l2": "do_9e90c447-7b87-42d9-898b-6e6fbc990957",
29+
"l3": "do_869422f8-20ea-4e43-9f13-26c666c416d2",
30+
"l4": "do_3e187467-d966-4e6e-9af1-ea057acce678"
31+
}
32+
},
33+
"object": {
34+
"id": "do_21274813398450176015065",
35+
"type": "Community",
36+
"ver": "3",
37+
"rollup": {
38+
"l1": "do_21273610197362278414264",
39+
"l2": "do_21271780182595993616932",
40+
"l3": "do_312469507013812224118164",
41+
"l4": "do_21271780182595993616932"
42+
}
43+
},
44+
"edata": {
45+
"type": "workflow",
46+
"subtype": "Scroll",
47+
"pageid": "c5577e38-6c47-4795-952b-143057fdb15a",
48+
"uri": "/workspace/content/create",
49+
"duration": 9,
50+
"visits": []
51+
},
52+
"tags": []
53+
}
54+
```
55+
56+
Here, `ets` is the unix timestamp of when the event ocurred, and `edata.uri` is the relative URL of the page that was visited. Using these 2 attributes from IMPRESSION events, a graph like the below one can be generated. To do this, aggregate the events based on date, and then count the number of events for each date. This data can be used to plot a graph like above.
57+
58+
![Visits Graph using IMPRESSION events](<../../.gitbook/assets/recipe-visits-bar-graph.png>)
59+
60+
61+
Likewise, by aggregating on the `edata.uri` a table representing page wise total views may be generated.
62+
63+
![Visits Graph using IMPRESSION events](<../../.gitbook/assets/recipe-views-pagewise.png>)

0 commit comments

Comments
 (0)