Skip to content

Commit e218ee0

Browse files
Add content about overwriting context fields (#1039)
1 parent a139452 commit e218ee0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/connections/sources/catalog/libraries/website/javascript/troubleshooting.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,25 @@ console.log(JSON.stringify({ x: undefined, y: 6 }));
112112
// expected output: "{"y":6}"
113113
```
114114

115+
116+
### Can I overwrite the context fields?
117+
118+
Yes. This can be useful if some of these fields contain information you don't want to collect.
119+
120+
For example, imagine that your website allows users to view a receipt for purchases at the URL `https://mywebsite.com/store/purchases`. Your users click a link that redirects to that specific URL, your app sets a `receiptId` in the query string, and returns the appropriate receipt. You also send a Track call to Segment from this page.
121+
122+
Since this `receiptId` might contain sensitive information, you can prevent the context field `page.url` from being included in your Track call by overwriting the field in the `options` parameter, as in the example below:
123+
124+
```js
125+
analytics.track("Receipt Viewed", {}, {
126+
page: {
127+
url: null
128+
}
129+
})
130+
```
131+
132+
This works for any [context field](/docs/connections/spec/common/#context) that Segment automatically collects.
133+
115134
## Known Issues:
116135

117136
[Review and contribute to these on Github](https://github.com/segmentio/analytics.js/issues)

0 commit comments

Comments
 (0)