interaction-tracker
v0.1.4
Published
A module to track customer interactions and send them to an AWS endpoint to store.
Downloads
86
Readme
A module to track customer interactions and send them to an AWS endpoint to store.
Install
npm install interaction-tracker
Author
👤 AC Lens
Sample Usage
import interactionTracker from 'interaction-tracker';
const itemIdGetter = (triggerElement: HTMLElement) => {
return triggerElement.getAttribute('personalize-itemId') || '';
};
const isRealPerson = true; // replace with bot detection
const interactionTrackerApiAddress = 'https://api-endpoint-provided-by-aclens.com';
const userId = 1234567; // customerId or unique cookieId
const sessionId = 1234567;
const init = () => {
if (!isRealPerson) {
return;
}
interactionTracker.init({
apiBaseUrl: interactionTrackerApiAddress,
userId,
impressionTracker: {
selector: '[personalize-product]',
getItemId: itemIdGetter,
},
interactions: [
{
selector: '[personalize-product]',
eventType: 'click',
interactionName: 'product-click',
getItemId: itemIdGetter,
},
{
selector: '[personalize-swatch]',
eventType: 'click',
interactionName: 'swatch-click',
getItemId: itemIdGetter,
},
{
selector: '[personalize-favorite]',
eventType: 'click',
interactionName: 'product-favorited',
getItemId: itemIdGetter,
},
{
selector: '[personalize-cart]',
eventType: 'click',
interactionName: 'product-added-to-cart',
getItemId: itemIdGetter,
},
],
sessionId,
});
};
export default init;
Show your support
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator