Skip to content

Commit a4b496a

Browse files
ashton-huxtablemarkzegarelli
andauthored
Update AJS FAQs to include adding new context fields (#4102)
* Update AJS FAQs to include adding new context fields * Include note that custom context may not be forwarded to destinations * Apply suggestions from code review Co-authored-by: markzegarelli <[email protected]>
1 parent 1630cb2 commit a4b496a

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
@@ -131,6 +131,25 @@ analytics.track("Receipt Viewed", {}, {
131131

132132
This works for any [context field](/docs/connections/spec/common/#context) that Segment automatically collects.
133133

134+
### Can I add context fields that do not already exist?
135+
136+
Yes. Similar to overwriting context, you can add context fields by passing them into the options object as the third argument of the event call. For example, the analytics.js library does not automatically collect location information. To add this into the context object, pass it into the third argument as in the example below:
137+
138+
```js
139+
analytics.track("Order Completed", {}, {
140+
location: {
141+
latitude: '39.7392',
142+
longitude: '104.9903'
143+
}
144+
})
145+
```
146+
147+
> info ""
148+
> You must pass the context object with the call, event if it's empty, as shown by the empty object in the example above.
149+
150+
Some destinations accept properties only. As a result, custom context fields you add may not forward to these destinations.
151+
152+
134153
## Known issues:
135154

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

0 commit comments

Comments
 (0)