@bikdotai/bik-event-tracker
v0.0.19
Published
Using Bik's Mobile Event Tracker you can track events in your mobile app and send them to Bik's servers.
Downloads
8
Readme
Using Bik's Mobile Event Tracker you can track events in your mobile app and send them to Bik's servers.
Introduction
The integration is straightforward and can be done quickly. There are three basic steps in the integration
- Initialize the tracker
- Identify the customer
- Log the events
Initialize the tracker
The init function takes in the shopify domain as a parameter. This is the domain of the shopify store that you are integrating with.
Please note this needs to be without https in the format bik.myshopify.com
If you want a testing domain, please contact Bik.
import { BikEventTracker } from '@bikdotai/bik-event-tracker'
const eventTracker = BikEventTracker.getInstance();
await eventTracker.init('bik.myshopify.com');
Identifying the user
You can identify the customer using the identify function. This function takes in a customer identification object which can take in
- customerId: The shopify customer id
- email: The email of the customer
- phoneNumber: The phone number of the customer
const customerIdentification = {
customerId: '123', // shopify's partner customer id
email: '[email protected]',
phoneNumber: '1234567890'
};
await eventTracker.idenitfy(customerIdentification);
Logging events
Once you have identified the customer you can log these three events
- Add to cart
- Page viewed
- Product viewed
const addToCartEvent: AddToCartAppEvent = {
productId: '123',
variantId: '123'
};
const pageViewedEvent: PageViewedAppEvent = {
title: 'Test Page'
};
const productViewedEvent: ProductViewedAppEvent = {
productId: '123',
variantId: '123'
};
await eventTracker.track({
eventName: 'addToCart',
eventProperties: addToCartEvent
});
await eventTracker.track({
eventName: 'pageViewed',
eventProperties: pageViewedEvent
});
await eventTracker.track({
eventName: 'productViewed',
eventProperties: productViewedEvent
});
Enabling debugging
We can enable debugging by passing an extra parameter to the app. This will enable logging to help you identify issues
import { BikEventTracker } from '@bikdotai/bik-event-tracker'
const eventTracker = BikEventTracker.getInstance();
await eventTracker.init('bik.myshopify.com', true);