Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1006 Bytes

README.md

File metadata and controls

48 lines (33 loc) · 1006 Bytes

react-tracker

Component level tracking using context

Examples

import {withTracker, useTracker} from '@lunrdigital/react-tracker';

const Component = () => {
    const { track } = useTracker();

    return (
        <button onClick={() => track('Button click')}>Track</button>
    );
};

const TrackedComponent = withTracker(Component, 'Default Category');

<TrackedComponent />

<TrackedComponent tracking-category="Overidden Category" />
import {withTracker, useTracker} from '@lunrdigital/react-tracker';

const Nested = () => {
    const { track } = useTracker();

    return (
        <button onClick={() => track('Nested button click')}>Track</button>
    );
};

const Component = () => {
    const { track } = useTracker();

    return (
        <button onClick={() => track('Button click')}>Track</button>
    );
};

const TrackedComponent = withTracker(Component, 'Default Category');

<TrackedComponent />

<TrackedComponent tracking-category="Overidden Category" />