Skip to content

Commit e555399

Browse files
committed
add event context to storefront event tracking docs
1 parent 6f311b6 commit e555399

File tree

1 file changed

+72
-2
lines changed

1 file changed

+72
-2
lines changed

docs/storefront/event-tracking.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,26 @@ console.log(init.user);
250250
</TabItem>
251251
</Tabs>
252252

253+
## Context
254+
255+
All events have `context` of the parent frame to easily access contextual data about where and how the event occurred.
256+
257+
| Property | Description | Reference |
258+
|-------------|------------------------|---------------|
259+
| `document` | Data from the top-frame `document` object (e.g., title, referrer). | [Document](https://developer.mozilla.org/en-US/docs/Web/API/Document) |
260+
| `navigator` | Data from the top-frame `navigator` object (e.g., userAgent, language). | [Navigator](https://developer.mozilla.org/en-US/docs/Web/API/Navigator) |
261+
| `window` | Data from the top-frame `window` object (e.g., innerWidth, location). | [Window](https://developer.mozilla.org/en-US/docs/Web/API/Window) |
262+
263+
```json title="Example conext object"
264+
{
265+
"context": {
266+
"document": {...}, // frame parent document
267+
"navigator": {...}, // frame parent navigator
268+
"window": {...} // frame parent window
269+
}
270+
}
271+
```
272+
253273
## Available Tracking Events
254274

255275

@@ -266,6 +286,11 @@ analytics.subscribe("page_viewed", event => {
266286
```json
267287
{
268288
"object": "page",
289+
"context": {
290+
"document": {...}, // frame parent document
291+
"navigator": {...}, // frame parent navigator
292+
"window": {...} // frame parent window
293+
},
269294
"data": {},
270295
"event_type": "page_viewed",
271296
"timestamp": "2024-12-09T06:42:47.750998+00:00",
@@ -290,6 +315,11 @@ analytics.subscribe("product_category_viewed", event => {
290315
```json
291316
{
292317
"object": "products",
318+
"context": {
319+
"document": {...}, // frame parent document
320+
"navigator": {...}, // frame parent navigator
321+
"window": {...} // frame parent window
322+
},
293323
"data": [
294324
{
295325
"id": 111,
@@ -434,6 +464,11 @@ analytics.subscribe("product_viewed", event => {
434464

435465
{
436466
"object": "product",
467+
"context": {
468+
"document": {...}, // frame parent document
469+
"navigator": {...}, // frame parent navigator
470+
"window": {...} // frame parent window
471+
},
437472
"data": {
438473
"id": 111,
439474
"url": "https://examplestore.com/catalogue/timeless-watch_111/",
@@ -550,6 +585,11 @@ analytics.subscribe("product_added_to_cart", event => {
550585
```json
551586
{
552587
"object": "cart_line",
588+
"context": {
589+
"document": {...}, // frame parent document
590+
"navigator": {...}, // frame parent navigator
591+
"window": {...} // frame parent window
592+
},
553593
"data": {
554594
"currency": "USD",
555595
"interval": null,
@@ -590,6 +630,11 @@ analytics.subscribe("product_removed_from_cart", event => {
590630
```json
591631
{
592632
"object": "cart_line",
633+
"context": {
634+
"document": {...}, // frame parent document
635+
"navigator": {...}, // frame parent navigator
636+
"window": {...} // frame parent window
637+
},
593638
"data": {
594639
"currency": "USD",
595640
"interval": null,
@@ -630,6 +675,11 @@ analytics.subscribe("checkout_started", event => {
630675
```json
631676
{
632677
"object": "checkout",
678+
"context": {
679+
"document": {...}, // frame parent document
680+
"navigator": {...}, // frame parent navigator
681+
"window": {...} // frame parent window
682+
},
633683
"data": {
634684
"number": null,
635685
"status": null,
@@ -718,6 +768,11 @@ analytics.subscribe("checkout_contact_info_submitted", event => {
718768
```json
719769
{
720770
"object": "checkout",
771+
"context": {
772+
"document": {...}, // frame parent document
773+
"navigator": {...}, // frame parent navigator
774+
"window": {...} // frame parent window
775+
},
721776
"data": {
722777
"number": null,
723778
"status": null,
@@ -816,7 +871,12 @@ analytics.subscribe("checkout_shipping_address_submitted", event => {
816871
```json
817872
{
818873
"object": "checkout",
819-
"data": {
874+
"context": {
875+
"document": {...}, // frame parent document
876+
"navigator": {...}, // frame parent navigator
877+
"window": {...} // frame parent window
878+
},
879+
"data": {
820880
"number": null,
821881
"status": null,
822882
"fulfillment_status": null,
@@ -926,7 +986,12 @@ analytics.subscribe("checkout_shipping_method_submitted", event => {
926986
```json
927987
{
928988
"object": "checkout",
929-
"data": {
989+
"context": {
990+
"document": {...}, // frame parent document
991+
"navigator": {...}, // frame parent navigator
992+
"window": {...} // frame parent window
993+
},
994+
"data": {
930995
"number": null,
931996
"status": null,
932997
"fulfillment_status": null,
@@ -1038,6 +1103,11 @@ analytics.subscribe("checkout_completed", event => {
10381103
```json
10391104
{
10401105
"object": "checkout",
1106+
"context": {
1107+
"document": {...}, // frame parent document
1108+
"navigator": {...}, // frame parent navigator
1109+
"window": {...} // frame parent window
1110+
},
10411111
"data": {
10421112
"number": "109659",
10431113
"status": "open",

0 commit comments

Comments
 (0)