An official plugin to add the Hardal tracking snippet to your React JS project.
npm install --save hardal
or
yarn add hardal
//index.ts
import SendToHardal from 'hardal'
//index.ts
const sendCustomEvent = () => {
const config = {
apiKey: '',
customDomain: '',
projectId: 372905,
eventType: 'click-request-demo',
eventValue: '',
eventData: {
path: window.location.pathname,
referrer: document.referrer,
position: 'header',
isUserLogin: false,
// Add any properties as needed
},
};
SendToHardal(config);
}
In the above example, the sendCustomEvent function is called with a configuration object named config. The configuration object includes the following properties:
apiKey
: Your Hardal API key. Replace 'YOUR_API_KEY' with your actual API key. To get create your Hardal account, raise a request here.customDomain
: Add your custom domain to bypassing adblocker and more data accuracy through server-side. e.g., 'ss.yourdomain.com').projectId
: The ID of the project to which you want to send the event.eventType
: The type of the event (e.g., 'click-request-demo').eventValue
: The value associated with the event (leave it as an empty string for now, or provide a specific value if needed).eventData
: An object containing additional data related to the event, such as path, referrer, product SKU, user type or any value. You can add more properties to the eventData object as needed.