File size: 944 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# withTrackingTool
This high-order component allows us to load a tracking tool when component gets mounted.
The `withTrackingTool` is called with a `trackingTool` parameter. Currently, only the `HotJar` tracking tool is supported.
The return is a wrapper function that takes your component and loads the specified tracking tool on top of it.
## Usage
When directly wrapping a component:
```js
import withTrackingTool from 'calypso/lib/analytics/with-tracking-tool';
class MyComponent {
render() {
// Something
}
}
export default withTrackingTool( 'HotJar' )( MyComponent );
```
When combined with other wrappers (like `localize()`):
```js
import { localize } from 'i18n-calypso';
import { flowRight } from 'lodash';
import withTrackingTool from 'calypso/lib/analytics/with-tracking-tool';
class MyComponent {
render() {
// Something
}
}
export default flowRight( localize, withTrackingTool( 'HotJar' ) )( MyComponent );
```
|