Installation
npm install -S analytica.click
How to use
Wrap your top level component with the AnalyticaClickProvider
import { AnalyticaClickProvider } from 'analytica.click';
<AnalyticaClickProvider values={{ analyticaToken: 'your api token' }} >
<Your Components....>
</AnalyticaClickProvider>
Example of automatic page tracking
import { useAnalytica } from 'analytica.click';
...
let lastLocation='';
...
YourComponent(){
const { page } = useAnalytica();
useEffect(() => {
if (<current path name> !== lastLocation) {
// will use window location
page({});
lastLocation = <current path name>;
}
}, [page, <current path name>]);
...
}
Example of event tracking
import { useAnalytica } from 'analytica.click';
...
const { event } = useAnalytica();
event({ eventName: 'my event name' });
Example of integrating analytica.click with your github build pipeline
- name: notify analytica of build
if: always()
uses: andreigecanalytica/analytica.click.gh@v2
with:
ANALYTICA_TOKEN: '${{ secrets.ANALYTICA_TOKEN }}'