Add the SDK dependency
Choose your preferred installation method.Initialize the SDK
Add this Javascript sdk script to your code and your SDK is ready to send events.YOUR_API_KEY and YOUR_SECRET_KEY with the credentials available in your Twinalyze project.
Initialize the SDK only once. After initialization, Twinalyze creates the device and session identifiers and starts collecting supported website events.
Enable Firebase Cloud Messaging
The complete configuration allows you to manage sessions, automatic event tracking, site search, file downloads, and Firebase Cloud Messaging.Twinalyze FCM Service Worker
Download the worker file and add your Firebase configuration.
twinalyze-fcm-sw.jsPlace this file in your application’s public root directory.
Request notification permission
Notification permission must be requested after a user action, such as clicking an Enable Notifications button. Call the function from a button:FCM works only when the browser supports notifications, FCM is enabled, the service worker is publicly available, and notification permission is granted.