Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gb-tracker-client

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gb-tracker-client

GroupBy client-side event tracker

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.7K
increased by311.56%
Maintainers
1
Weekly downloads
 
Created
Source

GroupBy Tracking Client

CircleCI Coverage Status

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-2.0.0.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');

// Must set the visitor at least once before any events are sent
// Should be called on login/logout or any time the visitorId/sessionId change
gbTracker.setVisitor('visitorId', 'sessionId');

// There are five event API's.

// AddToBasket events
gbTracker.sendAddToCartEvent({
 cart: {
   id: 'asfasdf',                     // Optional
   items:[  
     {
        productId:  'asdfasd',
        title:      'super boat',
        price:      100.21,
        quantity:   20,
        collection: 'testcollection',  // Optional: Defaults to 'Default'
        category:   'boats',           // Optional
        sku:        'asdfasf98',       // Optional
        margin:     0.81,              // Optional
        metadata: [                    // Optional
           {
             key: 'some key',
             value: 'some value'
           }
         ]
      }
   ],
   metadata: [                          // Optional
      {
        key: 'some key',
        value: 'some value'
      }
    ]
 },
 metadata: [                            // Optional
   {
     key: 'some key',
     value: 'some value'
   }
 ]
});

// Order events
gbTracker.sendOrderEvent({
 cart: {
   id: 'asfasdf',                     // Optional
   totalItems: 1,                     // Optional
   totalQuantity: 20,                 // Optional
   totalPrice: 1039.90,               // Optional
   items:[  
     {
        productId:  'asdfasd',
        title:      'super boat',
        price:      100.21,
        quantity:   20,
        collection: 'testcollection',  // Optional: Defaults to 'Default'
        category:   'boats',           // Optional
        sku:        'asdfasf98',       // Optional
        margin:     0.81,              // Optional
        metadata: [                    // Optional
           {
             key: 'some key',
             value: 'some value'
           }
         ]
      }
   ],
   metadata: [                          // Optional
      {
        key: 'some key',
        value: 'some value'
      }
    ]
 },
 metadata: [                            // Optional
   {
     key: 'some key',
     value: 'some value'
   }
 ]
});

// Search events
gbTracker.sendSearchEvent({
  search:   {
    origin:           {                       // Optional: Search defaults to true
      recommendations: false,
      dym:             false,
      sayt:            false,
      search:          true
    },
    totalRecordCount: 122,
    area:             'Default',
    biasingProfile:   'ThisBiasingProfile',   // Optional
    query:            'i searched for this',
    pageInfo: {           
      recordStart: 1,
      recordEnd:   24
    },
    matchStrategy: {                          // Optional: matchStrategy returned by searchandiser
      rules: [
        {
          termsGreaterThan: 1,
          mustMatch:        100,
          percentage:       true
        }
      ]
    },
    availableNavigation: [                    // Optional: Array of selectedNavigations returned by searchandiser
      {
        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: [],  // Optional: Array of selectedNavigations returned by searchandiser
    records:            [],  // Optional: Array of records returned by searchandiser
    didYouMean: [
      'I should have searched for this'
    ]
  }
});

// Auto Search events
gbTracker.sendAutoSearchEvent({
  // Provided in search response from API
  responseId: 'e30a4611-64b0-49a1-ad56-ab8fa2ffcc10',   
  search:   {
    origin:           {              // Optional: Search defaults to true  
      recommendations: false,
      dym:             false,
      sayt:            false,
      search:          true
    }    
 }
});

// ViewProduct events
gbTracker.sendViewProductEvent({
 product:  {
   productId:  'asdfasd',
   title:      'super boat',
   price:      100.21,
   collection: 'testcollection',  // Optional: Defaults to 'Default'
   category:   'boats',           // Optional
   sku:        'asdfasf98',       // Optional
   margin:     0.81,              // Optional
   metadata: [                    // Optional
      {
        key: 'some key',
        value: 'some value'
      }
    ]
 },
 metadata: [                            // Optional
   {
     key: 'some key',
     value: 'some value'
   }
 ]
});

// There are also navigation events, which are sent silently when page or URL changes

Keywords

FAQs

Package last updated on 13 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc