Skip to content

Track a product click with npm

This tutorial demonstrates how to track a ProductClicked event when a user clicks on a product in the webshop.

Before you start

Set up the npm client as described in the developer overview.

Step 1: Track the product click

Call trackProductClicked with the product and SKU identifiers:

1
2
3
4
5
tracker.trackProductClicked({
    productId: 'PROD-001',
    skuId: 'SKU-001-BLK-M',
    categoryId: 'CAT-SHOES',
})

The categoryId field is optional. Provide it when available to improve ranking and recommendation signals.

Step 2: Verify

Events are batched and sent automatically. The tracker flushes when the batch size is reached or the batch interval expires. A successful submission results in a 202 Accepted response from the Event Receiver.

Complete example

import { EventTracker } from '@bizzkit/event-tracking-sdk'

const tracker = new EventTracker({
    endpoint: 'https://event-tracking-eventreceiver.bizzkit.biz/api/events',
    instrumentationKey: 'your-instrumentation-key',
})

tracker.trackProductClicked({
    productId: 'PROD-001',
    skuId: 'SKU-001-BLK-M',
    categoryId: 'CAT-SHOES',
})

Warning

Please keep in mind that all examples provided are for illustrative purposes only. They are not intended to represent best practices and should not be used in production without a thorough code review.