GroupBy Tracking Client
This can be installed via npm with npm install --save gb-tracker-client
Or it can be directly included from our CDN using:
<script src="http://cdn.groupbycloud.com/dist/gb-tracker-client-1.4.6.min.js"></scipt>
Including it directly from the CDN will create the global variable
_GbTracker
with the same API as below.
Recommendations API can be found here
gb-tracker-client API
var _GbTracker = require('gb-tracker-client');
var gbTracker = new GbTracker('customerId', 'area');
gbTracker.setVisitor('visitorId', 'sessionId');
gbTracker.sendAddToCartEvent({
cart: {
id: 'asfasdf',
items:[
{
productId: 'asdfasd',
title: 'super boat',
price: 100.21,
quantity: 20,
collection: 'testcollection',
category: 'boats',
sku: 'asdfasf98',
margin: 0.81,
metadata: [
{
key: 'some key',
value: 'some value'
}
]
}
],
metadata: [
{
key: 'some key',
value: 'some value'
}
]
},
metadata: [
{
key: 'some key',
value: 'some value'
}
]
});
gbTracker.sendOrderEvent({
cart: {
id: 'asfasdf',
totalItems: 1,
totalQuantity: 20,
totalPrice: 1039.90,
items:[
{
productId: 'asdfasd',
title: 'super boat',
price: 100.21,
quantity: 20,
collection: 'testcollection',
category: 'boats',
sku: 'asdfasf98',
margin: 0.81,
metadata: [
{
key: 'some key',
value: 'some value'
}
]
}
],
metadata: [
{
key: 'some key',
value: 'some value'
}
]
},
metadata: [
{
key: 'some key',
value: 'some value'
}
]
});
gbTracker.sendSearchEvent({
search: {
origin: {
recommendations: false,
dym: false,
sayt: false,
search: true
},
totalRecordCount: 122,
area: 'Default',
biasingProfile: 'ThisBiasingProfile',
query: 'i searched for this',
pageInfo: {
recordStart: 1,
recordEnd: 24
},
matchStrategy: {
rules: [
{
termsGreaterThan: 1,
mustMatch: 100,
percentage: true
}
]
},
availableNavigation: [
{
name: 'reg_price',
displayName: 'Price',
refinements: [
{
type: 'Range',
count: 3,
high: '50',
low: '20'
},
{
type: 'Range',
count: 25,
high: '100',
low: '50'
},
{
type: 'Range',
count: 84,
high: '150',
low: '100'
},
{
type: 'Range',
count: 10,
high: '200',
low: '150'
}
],
metadata: [],
range: true,
or: false
}
],
selectedNavigation: [],
records: [],
didYouMean: [
'I should have searched for this'
]
}
});
gbTracker.sendAutoSearchEvent({
responseId: 'e30a4611-64b0-49a1-ad56-ab8fa2ffcc10',
search: {
origin: {
recommendations: false,
dym: false,
sayt: false,
search: true
}
}
});
gbTracker.sendViewProductEvent({
product: {
productId: 'asdfasd',
title: 'super boat',
price: 100.21,
collection: 'testcollection',
category: 'boats',
sku: 'asdfasf98',
margin: 0.81,
metadata: [
{
key: 'some key',
value: 'some value'
}
]
},
metadata: [
{
key: 'some key',
value: 'some value'
}
]
});