You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/connections/sources/catalog/libraries/website/javascript/faq.md
+13-12Lines changed: 13 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -9,16 +9,16 @@ Analytics.js doesn't automatically collect IPv6 addresses. If IPv6 is available
9
9
10
10
## Is there a size limit on requests?
11
11
12
-
Yes, the limit is 32KB per event message. Events with a payload larger than 32KB are not accepted by Analytics.js. Segment servers return a 400 response with the error message: `Exceed payload limit`.
12
+
Yes, the limit is 32 KB per event message. Events with a payload larger than 32 KB are not accepted by Analytics.js. Segment servers return a 400 response with the error message: `Exceed payload limit`.
13
13
14
14
## If Analytics.js fails to load, are callbacks not fired?
15
15
16
-
In the event that Analytics.js does not load, callbacks passed into your API calls do not fire. This is as designed, because the purpose of callbacks are to provide an estimate that the event was delivered and if the library never loads, the events won't be delivered.
16
+
In the event that Analytics.js does not load, callbacks passed into your API calls do not fire. This is by design, because the purpose of a callback is to provide an indication that the event was delivered. If the library never loads, the events won't be delivered.
17
17
18
18
## Is there an updated version of the Segment snippet?
19
19
Segment released an updated version of the Analytics.js snippet, which introduces several enhancements and fixes that might improve your setup. For a full list of version updates, see the Analytics.js snippet's [Releases](https://github.com/segmentio/snippet/releases){:target="_blank”}.
20
20
21
-
You can find the latest version of the Segment snippet in your JavaScript source's Overview tab or in the [Quickstart: Analytics.js](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2a-add-the-segment-snippet) documentation.
21
+
You can find the latest version of the Segment snippet in your JavaScript source's **Overview** tab or in the [Quickstart: Analytics.js](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2a-add-the-segment-snippet) documentation.
22
22
23
23
While there is no deadline to upgrade your snippet to the latest version, upgrading lets you use the latest improvements in the Segment library.
24
24
@@ -27,16 +27,16 @@ While there is no deadline to upgrade your snippet to the latest version, upgrad
27
27
28
28
In May 2018, Segment began collecting client-side performance metrics in Analytics.js. This includes metrics like:
29
29
30
-
- When clientside integrations are initialized and when they fail
31
-
- When messages are sent to clientside integrations and when they fail
30
+
- When client-side integrations are initialized and when they fail
31
+
- When messages are sent to client-side integrations and when they fail
32
32
33
-
Segment added these metrics to proactively identify and resolve issues with individual client-side integrations. These metrics are connected to alerts that notify Segment's on-call engineers to take action on these quickly.
33
+
Segment added these metrics to proactively identify and resolve issues with individual client-side integrations. These metrics trigger alerts that notify Segment's on-call engineers to take action promptly.
34
34
35
35
There should be no noticeable impact to your data flow. You may notice Analytics.js make an extra network request in the network tab to carry the metrics data to Segment's servers. This extra network request is not made frequently, since the data is sampled and batched every 30 seconds.
36
36
37
37
## How are properties with `null` and `undefined` values treated?
38
38
39
-
Segment treats property values set to `null` as null values and drops events set to`undefined`.
39
+
Segment treats property values set to `null` as null values and drops events set to`undefined`.
Segment uses the [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify){:target="blank"} method under the hood.
51
+
51
52
## Can I overwrite the context fields?
52
53
53
54
Yes. This can be useful if some of these fields contain information you don't want to collect.
This works for any [context field](/docs/connections/spec/common/#context) that Segment automatically collects.
67
68
68
-
When working with Page calls, you can overwrite context fields by following the above instructions. However, because the `context.page` fields are also available in the `properties` parameter for page calls, you must also prevent the same fields in the `properties` parameter from being included in your Page call. Use the code in the following example to overwrite `url` available in context field `page.url` and properties parameter:
69
+
When working with Page calls, you can overwrite context fields by following the above instructions. However, because the `context.page` fields are also available in the `properties` parameter for Page calls, you must also prevent the same fields in the `properties` parameter from being included in your Page call. Use the code in the following example to overwrite `url` available in context field `page.url` and properties parameter:
## Can I add context fields that do not already exist?
81
82
82
-
Yes. 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, but you can add it to the context object. To add location information into the context object, pass it into the third argument as in the following example:
83
+
Yes. 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, but you can add it to the context object. To add location information into the context object, pass it into the third argument as in the following example:
83
84
84
85
```js
85
86
analytics.track("Order Completed", {}, {
@@ -97,7 +98,7 @@ Some destinations accept properties only. As a result, custom context fields you
97
98
98
99
## What is the impact of exposing the source's write keys?
99
100
100
-
Segment's library architecture requires you to expose the write key for client-side tracking to work. Other major tools, like Google Analytics, Mixpanel, Kissmetrics, Hubspot, and Marketo, also require you to expose your write key.
101
+
Segment's library architecture requires you to expose the write key for client-side tracking to work. Other major tools, like Google Analytics, Mixpanel, Kissmetrics, HubSpot, and Marketo, also require you to expose your write key.
101
102
102
103
If you see any unusual behavior associated with your write key, generate a new key immediately. To generate a new key, navigate to **Connections > Sources** and select your source. On the **Settings** tab, go to the **API Keys** section and click **Generate New Key**.
103
104
@@ -126,7 +127,7 @@ You'll also need to modify the Segment script with your `nonce` tag, which shoul
126
127
127
128
## How is the referrer value set?
128
129
129
-
The Analytics.js library sets the `context.page.referrer` value from the [`window.document.referrer` property](https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer){:target="_blank"} set in the browser. If you notice unexpected referrer values reaching Segment, check how this value is being set on your website.
130
+
The Analytics.js library sets the `context.page.referrer` value from the [`window.document.referrer` property](https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer){:target="_blank"} set in the browser. If you notice unexpected referrer values reaching Segment, check how this value is set on your website.
130
131
131
132
## Are there any rate limits in place for the CDN settings endpoint?
132
133
@@ -142,4 +143,4 @@ If you need this functionality, you have a couple of options:
142
143
**Use a third-party API**: Alternatively, you can use third-party services like Geolocation API to convert IP addresses to geolocation data. Afterward, you can pass this information as a trait in Identify calls or as a property in Track calls to Segment. This allows you to manage geolocation data according to your specific needs, though it will likely require engineering resources.
143
144
144
145
## Why is my payload populating incorrectly?
145
-
Payload parameters aren't populated in a guaranteed order. Your payload should still be ingested as long as all necessary parameters are included.
146
+
Payload parameters aren't populated in a guaranteed order. Your payload will still be ingested as long as all necessary parameters are included.
Copy file name to clipboardExpand all lines: src/connections/sources/catalog/libraries/website/javascript/identity.md
+30-24Lines changed: 30 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,11 @@ title: Managing identity in Analytics.js
3
3
strat: ajs
4
4
---
5
5
6
-
This page explains how Analytics.js identifies users, and passes userID and anonymousID data, and how to override and change this information.
6
+
This page explains how Analytics.js identifies users, passes `userID` and `anonymousID` data, and how to override and change this information.
7
7
8
-
## Segment ID Persistence
8
+
## Segment ID persistence
9
9
10
-
To ensure high fidelity, first-party customer data, Segment writes the user's IDs to the user's local storage, and uses that as the Segment ID on the cookie whenever possible. Local Storage is meant for storing this type of first-party customer information.
10
+
To ensure high fidelity, first-party customer data, Segment writes the user's IDs to the user's local storage, and uses that as the Segment ID on the cookie whenever possible. Local storage is meant for storing this type of first-party customer information.
11
11
12
12
If a user returns to your site after the cookie expires, Analytics.js looks for an old ID in the user's `localStorage`, and if one is found, sets it as the user's ID again in the new cookie. If a user clears their cookies _and_`localstorage`, all of the IDs are removed, and the user gets a completely new `anonymousID` when they next visit the page.
You can override the default-generated anonymousID in code using the methods described below:
34
-
-[Set anonymousId from the Segment snippet](#override-the-anonymous-id-from-the-segment-snippet) (before the `ready` method returns)
33
+
You can override the default-generated `anonymousID` in code using the methods described below:
34
+
-[Set anonymousId from the Segment snippet](#override-the-anonymous-id-from-the-segment-snippet) (before the Ready method returns)
35
35
-[Use a call to override the anonymousID](#override-the-default-anonymous-id-with-a-call)
36
36
-[Set `anonymousId` in the `options` object of a call](#override-the-anonymous-id-using-the-options-object)
37
37
@@ -43,9 +43,9 @@ You can get the user's current `anonymousId` using the following call:
43
43
analytics.user().anonymousId();
44
44
```
45
45
46
-
If the user's `anonymousId` is `null` (meaning not set) when you call this function, Analytics.js automatically generated and sets a new `anonymousId` for the user.
46
+
If the user's `anonymousId` is `null` (meaning not set) when you call this function, Analytics.js automatically generates and sets a new `anonymousId` for the user.
47
47
48
-
If you are using the npm library, the previous call returns a promise for `user()`. As a workaround, you'll need to grab the user's current `anonymousId` in the following way:
48
+
If you're using the npm library, the previous call returns a promise for `user()`. As a workaround, you'll need to grab the user's current `anonymousId` in the following way:
49
49
50
50
```js
51
51
analytics.instance?.user().anonymousId()
@@ -57,28 +57,28 @@ A user's `anonymousId` changes when any of the following conditions are met.
57
57
58
58
- The user clears their cookies _and_ `localstorage`.
59
59
- Your site or app calls [`analytics.reset()`](/docs/connections/sources/catalog/libraries/website/javascript/#reset-or-logout) during in the user's browser session.
60
-
- Your site or app calls `analytics.identify()` with a userId that is different from the current userId.
61
-
- Your site or app is setting `ajs_user_id` to an empty string or calling `analytics.user().id('')` before calling `analytics.identify()`. This sequence of events will result in a new anonymousId being set when `analytics.identify()` is called.
60
+
- Your site or app calls `analytics.identify()` with a `userId` that is different from the current `userId`.
61
+
- Your site or app is setting `ajs_user_id` to an empty string or calling `analytics.user().id('')` before calling `analytics.identify()`. This sequence of events will result in a new `anonymousId` being set when `analytics.identify()` is called.
62
62
63
63
64
64
### Override the Anonymous ID from the Segment snippet
65
65
66
-
You can also set the `anonymousId` immediately inside your Segment snippet, even before the `ready` method returns.
66
+
You can also set the `anonymousId` immediately inside your Segment snippet, even before the Ready method returns.
67
67
68
68
```js
69
69
analytics.load('writekey');
70
70
analytics.page();
71
71
analytics.setAnonymousId('ABC-123-XYZ');
72
72
```
73
73
74
-
Use this method if you are queueing calls before `ready` returns and they require a custom `anonymousId`. Keep in mind that setting the `anonymousId` in Analytics.js does not overwrite the anonymous tracking IDs for any destinations you're using.
74
+
Use this method if you are queueing calls before Ready returns and they require a custom `anonymousId`. Keep in mind that setting the `anonymousId` in Analytics.js does not overwrite the anonymous tracking IDs for any destinations you're using.
75
75
76
76
> info ""
77
-
> Device-mode destinations that load their code on your site _might_ also set their own anonymous ID for the user that is separate and different from the Segment generated one. Some destinations use the Segment `anonymousId`. Read the documentation for each Destination to find out if a Destination sets its own ID.
77
+
> Device-mode destinations that load their code on your site _might_ also set their own anonymous ID for the user that is separate and different from the Segment generated one. Some destinations use the Segment `anonymousId`. Read the documentation for each destination to find out if a destination sets its own ID.
78
78
79
79
### Override the default Anonymous ID with a call
80
80
81
-
If the default generated UUID does not meet your needs, you can override it`anonymousId` for the current user using either of the following methods.
81
+
If the default generated UUID does not meet your needs, you can override the`anonymousId` for the current user with either of the following methods:
82
82
83
83
```js
84
84
analytics.user().anonymousId('ABC-123-XYZ');
@@ -92,17 +92,19 @@ These methods behave exactly the same.
92
92
93
93
### Override the Anonymous ID using the options object
94
94
95
-
Or in the `options` object of [`identify`](/docs/connections/spec/identify/), [`page`](/docs/connections/spec/page/), or [`track`](/docs/connections/spec/track/) calls, like this:
95
+
You can override the `anonymousID`in the `options` object of [Identify](/docs/connections/spec/identify/), [Page](/docs/connections/spec/page/), or [Track](/docs/connections/spec/track/) calls, like this:
96
96
97
97
98
-
Set the anonymousId in the Options object using the format in the following examples.
98
+
Set the `anonymousId` in the `options` object using the format in the following examples.
99
99
100
-
The custom anonymousId persists when you use these methods, even if you do not explicitly specify the anonymousId in the calls.
100
+
The custom `anonymousId` persists when you use these methods, even if you do not explicitly specify the `anonymousId` in the calls.
101
101
102
-
For example, after the Track call below sets the anonId, any later track calls from this user will have the anonymousId of `ABC-123-XYZ`, even if it is not explicitly specified in the track call.
102
+
For example, after a Track call sets the `anonymousID` to `ABC-123-XYZ`, any additional Track calls from this user will have the same `anonymousId`, even if it's not explicitly specified in the Track call.
103
103
104
104
#### Override anonymousId in an Identify call
105
105
106
+
You can override `anonymousID` with an Identify call. For example:
This appends the `plan_id` trait to this Track event. This does _not_ add the name or email, since those traits were not added to the `context` object. You must do this for every following event you want these traits to appear on, as the `traits` object does not persist between calls.
175
+
This appends the `plan_id` trait to the Track event. This does _not_ add the name or email, since those traits were not added to the `context` object. You must do this for every following event you want these traits to appear on, as the `traits` object does not persist between calls.
170
176
171
177
By default, non-Identify events (like Track or Page) **don't automatically collect user traits** from previous Identify calls. To include traits from an `identify()` event in later events, you'll need to add them manually to the `context.traits` object within the `options` parameter.
172
178
@@ -180,9 +186,9 @@ Each Analytics.js method has an `options` parameter where you can pass the `cont
180
186
Adding traits to events is especially useful if you're using [Actions destinations](/docs/connections/destinations/actions/), since it makes those traits available for mapping in the destination’s configuration.
181
187
182
188
183
-
## Clearing Traits
189
+
## Clearing traits
184
190
185
-
You can pass an empty object to the `traits` object to clear _all_ cached traits for a User or Group.
191
+
You can pass an empty object to the `traits` object to clear _all_ cached traits for a user or group.
186
192
187
193
Traits are cached by default when you call the Identify and Group methods. You can clear the `traits` object for the user or group by passing `traits` an empty object:
You can use the `user` or `group` method as soon as the Analytics.js library loads, to return information about the currently identified user or group. This information is retrieved from the user's cookie.
204
+
You can use the User or Group method as soon as the Analytics.js library loads, to return information about the currently identified user or group. This information is retrieved from the user's cookie.
199
205
200
206
<!-- TODO: retrieves info from cookie, if they have any info - maybe link to the top section-->
201
207
202
208
203
209
> success ""
204
-
> **Tip:** You can wrap any reference to `user()` or `group()` in a [ready function block](/docs/connections/sources/catalog/libraries/website/javascript#ready) to ensure that Analytics.js has fully loaded so these methods are available.
210
+
> You can wrap any reference to `user()` or `group()` in a [ready function block](/docs/connections/sources/catalog/libraries/website/javascript#ready) to ensure that Analytics.js has fully loaded so these methods are available.
205
211
206
212
Examples:
207
213
@@ -228,7 +234,7 @@ analytics.ready(function() {
228
234
229
235
## Anonymizing IP
230
236
231
-
Segment automatically collects the user's IP address for device-based (iOS, Android, Analytics.js and Xamarin) events.
237
+
Segment automatically collects the user's IP address for device-based (iOS, Android, Analytics.js, and Xamarin) events.
232
238
233
239
> info "IPv6"
234
240
> At the moment, Segment doesn't support automatically collecting IPv6 addresses.
0 commit comments