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
* Remove default custom-event behavior (replace with GTM dataLayer[] push)
* Add tests for console.error in class decorator
* Build
* docs
* 4.0.0
* Remove roadmap (that's what GH Issues are for :) )
`@track()` expects two arguments, `trackingData` and `options`.
19
19
-`trackingData` represents the data to be tracked (or a function returning that data)
20
20
-`options` is an optional object that accepts three properties:
21
-
-`dispatch`, which is a function to use instead of the default CustomEvent dispatch behavior. See the section on custom `dispatch()` later in this document.
21
+
-`dispatch`, which is a function to use instead of the default dispatch behavior. See the section on custom `dispatch()` later in this document.
22
22
-`dispatchOnMount`, when set to `true`, dispatches the tracking data when the component mounts to the DOM. When provided as a function will be called on componentDidMount with all of the tracking context data as the only argument.
23
23
-`process`, which is a function that can be defined once on some top-level component, used for selectively dispatching tracking events based on each component's tracking data. See more details later in this document.
24
24
@@ -93,9 +93,9 @@ This is also how you would use this module without `@decorators`, although this
93
93
94
94
### Custom `options.dispatch()` for tracking data
95
95
96
-
By default, data tracking objects are dispatched as a CustomEvent on `document` (see [src/dispatchTrackingEvent.js](src/dispatchTrackingEvent.js)). You can override this by passing in a dispatch function as a second parameter to the tracking decorator `{ dispatch: fn() }` on some top-level component high up in your app (typically some root-level component that wraps your entire app).
96
+
By default, data tracking objects are pushed to `window.dataLayer[]` (see [src/dispatchTrackingEvent.js](src/dispatchTrackingEvent.js)). This is a good default if you use Google Tag Manager. You can override this by passing in a dispatch function as a second parameter to the tracking decorator `{ dispatch: fn() }` on some top-level component high up in your app (typically some root-level component that wraps your entire app).
97
97
98
-
For example, to push objects to `window.dataLayer[]` (e.g. for Google Tag Manager) instead, you would decorate your top-level `<App />` component like this:
98
+
For example, to push objects to `window.myCustomDataLayer[]` (e.g. for Google Tag Manager) instead, you would decorate your top-level `<App />` component like this:
99
99
100
100
```js
101
101
importReact, { Component } from'react';
@@ -266,10 +266,3 @@ Note that there are no restrictions on the objects that are passed in to the dec
266
266
**The format for the tracking data object is a contract between your app and the ultimate consumer of the tracking data.**
267
267
268
268
This library simply merges the tracking data objects together (as it flows through your app's React component hierarchy) into a single object that's ultimately sent to the tracking library.
269
-
270
-
271
-
## Roadmap
272
-
273
-
- Integration with [tracking-schema](https://github.com/nytm/tracking-schema) to provide developer warnings/errors on invalid data objects
274
-
- DataLayer adapters (so that where the data goes can vary by app, e.g. to EventTracker or Google Analytics etc.)
0 commit comments