Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9166469

Browse files
Merge pull request #7941 from segmentio/DOC-1187
A Full Segment Implementation review
2 parents e568653 + 3e7f29b commit 9166469

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

src/getting-started/04-full-install.md

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ related:
55
- "/connections/spec/best-practices-identify/"
66
---
77

8-
Before you start implementing from your tracking plan, let's review the Segment methods, what they do, and when you should use each.
8+
Before you start implementing from your tracking plan, review the Segment methods, what they do, and when you should use each method.
99

1010
## Segment methods in detail
1111

12-
Segment's libraries generate and send messages to our tracking API in JSON format, and provide a standard structure for the basic API calls. We also provide recommended JSON structure (also known as a schema, or 'Spec') that helps keep the most important parts of your data consistent, while allowing great flexibility in what other information you collect and where.
12+
Segment's libraries generate and send messages to Segment's tracking API in JSON format, and provide a standard structure for the basic API calls. Segment also provides recommended JSON structure, called a schema, or 'Spec', that helps keep the most important parts of your data consistent, while allowing great flexibility in what other information you collect and where.
1313

1414
There are six calls in the basic tracking API, which answer specific questions:
1515

@@ -20,14 +20,14 @@ There are six calls in the basic tracking API, which answer specific questions:
2020
- [Group](/docs/connections/spec/group/): What account or organization are they part of?
2121
- [Alias](/docs/connections/spec/alias/): What was their past identity?
2222

23-
Among these calls, you can think of Identify, Group, and Alias as similar types of calls, all to do with updating our understanding of the user who is triggering Segment messages. You can think of these calls as adding information to, or updating an object record in a database. **Objects** are described using "traits", which you can collect as part of your calls.
23+
Among these calls, you can think of Identify, Group, and Alias as similar types of calls, all to do with updating Segment's understanding of the user who is triggering messages. You can think of these calls as adding information to or updating an object record in a database. **Objects** are described using "traits", which you can collect as part of your calls.
2424

2525
The other three, Track, Page, and Screen, can be considered as increasingly specific types of events. **Events** can occur multiple times, but generate separate records which append to a list, instead of being updated over time.
2626

2727
A Track call is the most basic type of call, and can represent any type of event. Page and Screen are similar and are triggered by a user viewing a page or screen, however Page calls can come from both web and mobile-web views, while Screen calls *only* occur on mobile devices. Because of the difference in platform, the context information collected is very different between the two types of calls.
2828

2929
> success ""
30-
> Segment recommends that you always use the Page and Screen calls when recording a page-view, rather than creating a "Page Viewed" Track event, because the Page/Screen calls automatically collect more contextual information.
30+
> Segment recommends that you always use the Page and Screen calls when recording a page view rather than creating a "Page Viewed" Track event, because the Page/Screen calls automatically collect more contextual information.
3131
3232
## Anatomy of a Segment message
3333

@@ -38,6 +38,8 @@ A Track call is the most basic type of call, and can represent any type of event
3838

3939
<!---![An identify event that identifies Michael Phillips, a customer who lives in New York, New York.](images/identify-call.png)--->
4040

41+
The following code snippet is an example Identify call that identifies a user, Michael Phillips, a customer who lives in New York, New York.
42+
4143
```js
4244
analytics.identify (user_id: "12345abcde",
4345
traits: {
@@ -52,32 +54,28 @@ The Identify call allows Segment to know **who** is triggering an event.
5254

5355
### When to call Identify
5456

55-
Call Identify when the user first provides identifying information about themselves (usually during log in), or when they update their profile information.
57+
Call Identify when the user first provides identifying information about themselves (usually during the sign in process), or when they update their profile information.
5658

5759
When called as part of the login experience, you should call Identify as soon as possible after the user logs in. When possible, follow the Identify call with a Track event that records what caused the user to be identified.
5860

59-
When you make an Identify call as part of a profile update, you only need to send the changed information to Segment. You can send all profile info on every Identify call if that makes implementation easier, but this is optional.
61+
When you make an Identify call as part of a profile update, you only need to send the changed information to Segment. You can optionally send all profile info on every Identify call if that makes implementation easier.
6062

61-
> info "Learn More"
62-
> [Best Practices for Identifying Users](https://segment.com/docs/connections/spec/best-practices-identify/)
63+
For more information about best practices for identifying your users, see the [Best Practices for Identifying Users](/docs/connections/spec/best-practices-identify/) documentation.
6364

6465
## Traits in Identify calls
6566

6667
These are called [traits](/docs/connections/spec/identify/#traits) for Identify calls, and [properties](/docs/connections/spec/track/#properties) for all other methods.
6768

6869
**The most important trait to pass as part of the Identify call is userId**, which uniquely identifies a user across all applications.
6970

70-
You should use a hash value to ensure uniqueness, although other values are acceptable; for example, email address isn't the best thing to use as a userid, but is usually acceptable since it will be unique, and doesn't change often.
71+
You should use a hash value to ensure uniqueness, although other values are acceptable. For example, email address isn't the best thing to use as a userid, but is usually acceptable since it will be unique and doesn't change often.
7172

7273
Beyond that, the Identify call is your opportunity to provide information about the user that can be used for future reporting, so you should try to send any fields that you might want to report on later.
7374

74-
Consider using Identify and traits when:
75-
76-
- Gathering user profile data (for example, company, city/state, job title, or other user-level data)
77-
- Gathering company-level data (for example, company size, number of seats, etc)
75+
Consider using Identify and traits when gathering user profile data (like company, city/state, job title, or other user-level data) or company-level data (like company size, or number of seats).
7876

7977

80-
## How to Call Identify
78+
## How to call Identify
8179

8280
You can call Identify from any of Segment's device-based or server-based libraries, including [Javascript](/docs/connections/sources/catalog/libraries/website/javascript/), [iOS](/docs/connections/sources/catalog/libraries/mobile/ios), [Android](/docs/connections/sources/catalog/libraries/mobile/android), [Ruby](/docs/connections/sources/catalog/libraries/server/ruby/), and [Python](/docs/connections/sources/catalog/libraries/server/python/).
8381

@@ -112,11 +110,11 @@ analytics.identify( user_id: "12345abcde",
112110

113111

114112

115-
## Using analytics.reset()
113+
## Using Reset calls
116114

117-
When a user explicitly signs out of one of your applications, you can call `analytics.reset()` to stop logging further event activity to that user, and create a new `anonymousId` for subsequent activity (until the user logins in again and is subsequently identify-ed). **This call is most relevant for client-side Segment libraries**, as it clears cookies in the user's browser.
115+
When a user explicitly signs out of one of your applications, you can call Reset to stop logging further event activity to that user, and create a new `anonymousId` for subsequent activity (until the user logins in again and is subsequently identified). **This call is most relevant for client-side Segment libraries**, as it clears cookies in the user's browser.
118116

119-
Make a `reset()` call as soon as possible after sign-out occurs, and only after it succeeds (not immediately when the user clicks sign out). For more info on this call, [see the JavaScript source documentation](/docs/connections/sources/catalog/libraries/website/javascript/#reset-or-logout).
117+
Make a Reset call as soon as possible after sign-out occurs, and only after it succeeds (not immediately when the user clicks sign out). For more info on a Reset call, [see the JavaScript source documentation](/docs/connections/sources/catalog/libraries/website/javascript/#reset-or-logout).
120118

121119
## Page and Screen
122120

@@ -169,26 +167,26 @@ properties:@{ @"category": @"Smartwatches", @"sku": @"13d31" }];
169167
170168
### When to Call Page
171169
172-
Segment automatically calls a Page event whenever a web page loads. This might be enough for most of your needs, but if you change the URL path without reloading the page, for example in single page web apps, you must call Page manually .
170+
Segment automatically calls a Page event whenever a web page loads. This might be enough for most of your needs, but if you change the URL path without reloading the page, for example in single page web apps, you must call Page manually.
173171
174172
If the presentation of user interface components don't substantially change the user's context (for example, if a menu is displayed, search results are sorted/filtered, or an information panel is displayed on the exiting UI) **measure the event with a Track call, not a Page call.**
175173
176174
> info ""
177175
> When you manually trigger a Page call, make sure the call happens _after_ the UI element is successfully displayed, not when it is called. It shouldn't be called as part of the click event that initiates it.
178176
179-
For more info on Page calls, review [Page spec](/docs/connections/spec/page/) and [Analytics.js docs](/docs/connections/sources/catalog/libraries/website/javascript/#page).
177+
For more info on Page calls, review the [Page spec](/docs/connections/spec/page/) and [Analytics.js](/docs/connections/sources/catalog/libraries/website/javascript/#page) documentation.
180178
181179
### When to call Screen
182180
183-
Segment Screen calls are essentially the Page method, except for mobile apps. Mobile Screen calls are treated similarly to standard Page tracking, only they contain more context traits about the device. The goal is to have as much consistency between web and mobile as is feasible.
181+
Segment Screen calls are essentially the Page method for mobile apps. Mobile Screen calls are treated similarly to standard Page tracking, only they contain more context traits about the device. The goal is to have as much consistency between web and mobile as is feasible.
184182
185183
## Track calls
186184
187-
The Track call allows Segment to know **what** the user is doing.
185+
A Track call allows Segment to know **what** the user is doing.
188186
189187
### When to call Track
190188
191-
The Track call is used to track user and system events, such as:
189+
A Track call is used to track user and system events like:
192190
193191
- The user interacting with a UI component (for example, "Button Clicked")
194192
- A significant UI component appearing, other than a page (for example, search results or a payment dialog)
@@ -197,7 +195,7 @@ The Track call is used to track user and system events, such as:
197195
198196
Your Track calls should include both events and properties. **Events are the actions you want to track**, and **properties are the data _about_ the event that are sent with each event**.
199197
200-
[Properties](/docs/connections/spec/track/#properties) are powerful. They enable you to capture as much context about the event as you'd like, and then cross-tabulate or filter your downstream tools. For example, let's say an eLearning website is tracking whenever a user bookmarks an educational article on a page. Here's what a robust analytics.js Track call could look like:
198+
[Properties](/docs/connections/spec/track/#properties) are powerful. They enable you to capture as much context about the event as you'd like, and then cross-tabulate or filter your downstream tools. For example, if an eLearning website is tracking whenever a user bookmarks an educational article on a page. Here's what a robust Analytics.js Track call could look like:
201199
202200
```js
203201
analytics.track('Article Bookmarked', {
@@ -213,25 +211,23 @@ analytics.track('Article Bookmarked', {
213211
});
214212
```
215213

216-
With this Track call, we can analyze which authors had the most popular articles, which months and years led to the greatest volume of bookmarking overall, which button locations drive the most bookmark clicks, or which users gravitate towards infographics related to Data Planning.
214+
With this Track call, you can analyze which authors had the most popular articles, which months and years led to the greatest volume of bookmarking overall, which button locations drive the most bookmark clicks, or which users gravitate towards infographics related to Data Planning.
217215

218216
## Event Naming Best Practices
219217

220-
Each event you track must have a name that describes the event, like 'Article Bookmarked' above. That name is passed in at the beginning of the Track call, and should be standardized across all your properties so you can compare the same actions on different properties.
218+
Each event you track must have a name that describes the event, like 'Article Bookmarked' in the example above. That name is passed in at the beginning of the Track call, and should be standardized across all your properties so you can compare the same actions on different properties.
221219

222220
Segment's best practice is to use an “Object Action” (Noun<>Verb) naming convention for all **Track** events, for example, 'Article Bookmarked'.
223221

224222
Segment maintains a set of [**Business Specs**](/docs/connections/spec/semantic/) which follow this naming convention around different use cases such as eCommerce, B2B SaaS, and Mobile.
225223

226-
Let's dive deeper into the Object Action syntax that all Segment Track events should use.
227-
228224
### Objects are Nouns
229225

230226
Nouns are the entities or objects that the user or the system acts upon.
231227

232228
It's important to be thoughtful when naming objects so that they are referred to consistently within an application, and so that you refer to the same objects that might exist in multiple applications or sites by the same name.
233229

234-
Use the following list of objects to see if there is a logical match with your application. If you have objects that aren't in this list, name it in a way that makes sense if it were to appear in other applications, and/or run it by Product Analytics.
230+
Use the following list of objects to see if there is a logical match with your application. If you have objects that aren't in this list, name it in a way that makes sense if it were to appear in other applications, and/or run it by your Product Analytics team.
235231

236232
#### Some suggested Nouns
237233

@@ -254,25 +250,25 @@ If you can't, choose a verb that describes what the user is trying to do in your
254250

255251
- **Applied** - Applying a new format to the UI results.
256252
- **Clicked** - Catch-all for events where a user activated some part of the UI but no other verb captures the intent.
257-
- **Created/Deleted** - The user- or system-initiated action of creating or deleting an object (e.g., new search, favorite, post)
258-
- **Displayed/Hidden** - The user- or system-initiated action of hiding or displaying an element
259-
- **Enabled/Disabled** - Enabling or disabling some feature (e.g., audible alarms, emails, etc).
253+
- **Created/Deleted** - The user- or system-initiated action of creating or deleting an object (for example, new search, favorite, post).
254+
- **Displayed/Hidden** - The user- or system-initiated action of hiding or displaying an element.
255+
- **Enabled/Disabled** - Enabling or disabling some feature (for example, audible alarms, or emails).
260256
- **Refreshed** - When a set of search results is refreshed.
261-
- **Searched** - When an app is searched
257+
- **Searched** - When an app is searched.
262258
- **Selected** - User clicked on an individual search result.
263-
- **Sorted** - The user or UI action that causes data in a table, for example, to be sorted
259+
- **Sorted** - The user or UI action that causes data in a table, for example, to be sorted.
264260
- **Unposted** - Making a previously publicly-viewable posting private.
265-
- **Updated** - The user action that initiates an update to an object (profile, password, search, etc.; typically be making a call to the backend), or the they system having actually completed the update (often this tracking call will be made in response to a server-side response indicating that the object was updated, which may or may not have an impact on the UI).
266-
- **Viewed** - (exactly what it says on the tin)
261+
- **Updated** - The user action that initiates an update to an object (profile, password, or search). This might be a backend call or the system completing an update. This tracking call is often made in response to a server-side response indicating that the object was updated (which may or may not have an impact on the UI).
262+
- **Viewed** - The user viewed something.
267263

268264

269265
### Property naming best practices
270266

271267
Segment recommends that you record property names using **snake case** (for example `property_name`), and that you format property values to match how they are captured. For example, a `username` value would be captured in whatever case it the user typed it in as.
272268

273-
Ultimately, you can decide to use a casing different from our recommendations; however, **the single most important aspect is that you're consistent across your entire tracking with one casing method**.
269+
Ultimately, you can decide to use a casing different from Segment's recommendations; however, **the single most important aspect is that you're consistent across your entire tracking with one casing method**.
274270

275-
You can read more about [best practices for Track calls](/docs/connections/spec/best-practices-event/), .
271+
You can read more about best practices for Track calls in the [Best Practices for Track Calls](/docs/connections/spec/best-practices-event/) documentation.
276272

277273
All of the basic [Segment methods](/docs/connections/spec/) have a common structure and common fields which are automatically collected on every call. You can see these in the [common fields documentation](/docs/connections/spec/common/).
278274

0 commit comments

Comments
 (0)