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
`event`| | String | The name of the event you're tracking. You can read more about the [track method](/docs/connections/spec/track) and recommended event names.
127
-
`properties` | optional | Object | A dictionary of [properties](/docs/connections/spec/track#properties) for the event. If the event was `'Added to Cart'`, it might have properties like `price` and `productType`.
128
-
`options`| optional | Object | A dictionary of options. For example, [enable or disable specific destinations](#managing-data-flow-with-the-integrations-object) for the call. _Note: If you do not pass a `properties` object, pass an empty object (like '{}') before `options`_.
129
-
`callback`| optional | Function | A function that runs after a timeout of 300 ms, giving the browser time to make outbound requests first.
|`event`| String | The name of the event you're tracking. You can read more about the [track method](/docs/connections/spec/track) and recommended event names.|
127
+
|`properties`|Object |Optional. A dictionary of [properties](/docs/connections/spec/track#properties) for the event. If the event was `'Added to Cart'`, it might have properties like `price` and `productType`.|
128
+
|`options`| Object | Optional. A dictionary of options. For example, [enable or disable specific destinations](#managing-data-flow-with-the-integrations-object) for the call. _Note: If you do not pass a `properties` object, pass an empty object (like '{}') before `options`_.|
129
+
|`callback`| Function |Optional. A function that runs after a timeout of 300 ms, giving the browser time to make outbound requests first.|
130
130
131
131
The only required argument in Analytics.js is an _event name string_. You can read more about [how Segment recommends you name events](/docs/connections/spec/track#event).
132
132
@@ -326,12 +326,41 @@ For more details about Alias, including the **`alias` call payload**, check out
326
326
327
327
The Analytics.js utility methods help you change how Segment loads on your page. They include:
328
328
329
+
-[Load](#load)
329
330
-[Ready](#ready)
330
331
-[Debug](#debug)
331
332
-[On (Emitter)](#emitter)
332
333
-[Timeout](#extending-timeout)
333
334
-[Reset (Logout)](#reset-or-logout)
334
335
336
+
### Load
337
+
338
+
> info ""
339
+
> The `load` method is available when you load analytics.js through the [NPM package](https://www.npmjs.com/package/@segment/analytics-next){:target="_blank"}.
340
+
341
+
You can load a buffered version of analytics.js that requires you call `load` explicitly to before analytics.js initiates any network activity. This is useful if you want to, for example, wait for user consent before you fetch tracking destinations or send buffered events to Segment.
342
+
343
+
> warning ""
344
+
> Call `load` one time only.
345
+
346
+
```js
347
+
exportconstanalytics=newAnalyticsBrowser()
348
+
349
+
analytics.identify("hello world")
350
+
351
+
if (userConsentsToBeingTracked) {
352
+
analytics.load({ writeKey:'<YOUR_WRITE_KEY>' }) // destinations loaded, enqueued events are flushed
353
+
}
354
+
```
355
+
356
+
You can also use `load` if you fetch some settings asynchronously.
The `ready` method allows you to pass in a method that is called once Analytics.js finishes initializing, and once all enabled device-mode destinations load. It's like [jQuery's `ready` method](https://api.jquery.com/ready/){:target="_blank"}, except for Destinations.
0 commit comments