Skip to content

Commit 8ab6642

Browse files
authored
Update track.md - Track Spec added context.traits and actions destination info
1 parent c38a9e8 commit 8ab6642

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/connections/spec/track.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,57 @@ The following are all of the reserved properties Segment has standardized that a
114114
| `value` | Number | An abstract "value" to associate with an event. This is typically used in situations where the event doesn't generate real-dollar revenue, but has an intrinsic value to a marketing team, like newsletter signups. |
115115

116116
**Note:** You might be used to some destinations recognizing special properties differently. For example, Mixpanel has a special `track_charges` method for accepting revenue. Luckily, you don't have to worry about those inconsistencies. Just pass along `revenue`. **Segment will handle all of the destination-specific conversions for you automatically.** Same goes for the rest of the reserved properties.
117+
118+
119+
## Sending Traits in a Track Call - Destination Actions
120+
All events have the ability to include additional event data in the `context` object. There may be instances when your team may want to include user traits or group traits in a Track event, such as having a single event trigger multiple events in an Actions destination. Since user Traits are not standard fields for a Track event, in order to do this, you'll need to explicitely pass the user's traits into the event payload's `context.traits` object.
121+
_For instructions on how to pass fields to the context object for a specific library, please see the related library's Source documentation._
122+
123+
Segment's Actions destinations allows your team to build individual actions that are triggered based on a set of configured conditions. By adding the user's latest traits to the Track event's `context.traits` object, its possible to build two separate Actions to be triggered by this single event. For example, if your team would like to send an Identify event anytime the specific Track event "Button Clicked" is triggered, simply add the available traits into the Track event's payload, then build a destination Actions for the Track event : `Event Name is Button Clicked`, and a destination Action for the Identify event : `All of the following conditions are true: Event Name is Button Clicked, Event Context traits exists`, and then both Actions will have access to reference the `context.traits` fields within its mappings.
124+
125+
For more information on the context object, please see the [Spec: Common Fields](https://segment.com/docs/connections/spec/common/#context) documentation.
126+
127+
<table>
128+
{% include content/spec-table-header.md %}
129+
{% include content/spec-field-context.md %}
130+
</table>
131+
132+
If the [Example Payload](https://segment.com/docs/connections/spec/track/#example) shared above is modified as the event `Button Clicked` with `"username": "testing-123"` in the `context.traits` object, then the event's payload would be :
133+
```
134+
{
135+
"anonymousId": "23adfd82-aa0f-45a7-a756-24f2a7a4c895",
136+
"context": {
137+
"library": {
138+
"name": "analytics.js",
139+
"version": "2.11.1"
140+
},
141+
"page": {
142+
"path": "/academy/",
143+
"referrer": "",
144+
"search": "",
145+
"title": "Analytics Academy",
146+
"url": "https://segment.com/academy/"
147+
},
148+
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36",
149+
"ip": "108.0.78.21",
150+
"traits": {
151+
"username": "testing-123"
152+
}
153+
},
154+
"event": "Button Clicked",
155+
"integrations": {},
156+
"messageId": "ajs-f8ca1e4de5024d9430b3928bd8ac6b96",
157+
"properties": {
158+
"title": "Intro to Analytics"
159+
},
160+
"receivedAt": "2015-12-12T19:11:01.266Z",
161+
"sentAt": "2015-12-12T19:11:01.169Z",
162+
"timestamp": "2015-12-12T19:11:01.249Z",
163+
"type": "track",
164+
"userId": "AiUGstSDIg",
165+
"originalTimestamp": "2015-12-12T19:11:01.152Z"
166+
}
167+
```
168+
169+
Here's what that Identify Action would look like :
170+
![Identify Action - Triggered by Button Clicked Track event with context traits](https://github.com/segmentio/segment-docs/assets/68755692/552d418d-abdd-4ec5-9253-da931f22f164)

0 commit comments

Comments
 (0)