After installing the client, you must initialize it in your application code:
You should only initialize the client one time in your application.
index.ts
Copy
Ask AI
import { UnifyIntentClient, UnifyIntentClientConfig } from '@unifygtm/intent-client';const writeKey = 'YOUR_PUBLIC_API_KEY';const config: UnifyIntentClientConfig = { autoPage: true, autoIdentify: false,};const unify = new UnifyIntentClient(writeKey, config);// Do not call mount during server side rendering. Only call it in a browser context.unify.mount();
You can then use the resulting client instance to log intent data. See the
Client Spec for more details on how to use the client.
When you are done using the client, if you wish to clean up the side effects
generated by it, you can do so with the unmount method:
cleanup.ts
Copy
Ask AI
import { UnifyIntentClient, UnifyIntentClientConfig } from '@unifygtm/intent-client';const writeKey = 'YOUR_PUBLIC_API_KEY';const unify = new UnifyIntentClient(writeKey);unify.mount();// Use the client for some time, then later...unify.unmount();