1.2.0 • Published 4 months ago
@unifygtm/intent-react v1.2.0
Unify Intent React
Library for using the Unify Intent JS Client in a React app.
Installation
npm
npm install @unifygtm/intent-react
yarn
yarn add @unifygtm/intent-react
Usage
Wrap your React app in a UnifyIntentProvider
:
import {
UnifyIntentClient,
UnifyIntentClientConfig,
UnifyIntentProvider
} from '@unifygtm/intent-react';
const writeKey = 'YOUR_PUBLIC_API_KEY';
const config: UnifyIntentClientConfig = {
autoPage: true,
autoIdentify: false,
};
const intentClient = new UnifyIntentClient(writeKey, config);
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement,
);
root.render(
<UnifyIntentProvider intentClient={intentClient}>
<App />
</UnifyIntentProvider>
);
Then, any components rendered in your app can access the intent client
using the useUnifyIntent
hook:
import { useUnifyIntent } from '@unifygtm/intent-react';
const SomeComponent = () => {
// However you access the current user...
const currentUser = useCurrentUser();
const unify = useUnifyIntent();
useEffect(() => {
// Log an identify event for the current user
unify.identify(currentUser.emailAddress);
}, [currentUser.emailAddress]);
};
1.2.0
4 months ago
1.1.3
9 months ago
1.1.2
9 months ago
1.1.1
11 months ago
1.1.0
12 months ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago
0.1.5
1 year ago
0.1.4
1 year ago
0.1.3
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.1.0
1 year ago