@homeworksenergy/tracker
v1.0.0
Published
Custom Tracker
Downloads
4
Readme
tracker
Usage - Tracker
import React, { useEffect } from 'react';
import { tracker } from 'ecomm-lib';
// Recommended: For "tree-shakable" imports, you can access modules individually:
// import tracker from 'ecomm-lib/build/tracker';
export const App = () => {
// Initialize the tracker on App/page load.
useEffect(() => {
tracker.blacklisted = !isClient() || isBot();
tracker.sendToCustomService = yourCustomAPICallHere;
tracker.start();
// Cleanup when the App unmounts... Not typically necessary, but good practice!
return () => tracker.stop();
}, []);
const onClickButton = event => {
tracker.track('Clicked button', { customProp: 'Whatever data you want to send!' });
};
return (
<div>
Hello world!
<button onClick={onClickButton}>Track me!</button>
</div>
);
};