Earlybird SDK for JavaScript
Earlybirds Javascript is a wrapper for the Earlybirds API. It includes functions that allows you to trigger an identify, get some recommandations, and track activities.
Installation
npm install earlybirds-js
Requirements
This tutorial requires a basic understanding of the Earlybids API and we strongly recommend you to read the Earlybirds doc first.
Getting started
Initializing
First, we need to initialize the instance with a trackerKey using the init() method.
const eb = eb
Get a profile ID
Every time a user visits your page, you need to send an identify request to the API in order to retrieve his Earlybirds profile ID. See the Earlybirds doc (identify workflow).
const config = profile: datasources: id: 'DATASOURCE_ID' original_id: 'CUSTOMER_ID' eb
Get recommendations
Earlybirds-js provides a getRecommendations method that takes a widgetId as parameter and return a promise that resolves to a list of recommendations
eb
Track an activity
The trackActivity method allows you to track actions such as a view, a buy, ... Can be done anywhere after an identify
eb
Get Recommendations for a cluster
If the Early Birds profileId is not known, you can replace it with the couple datasourceId / userId.
eb
Get recos multi
Retrieve results from several recommendation widgets.
eb
Get Last activities
You can retrieve the list of user last activities, filtered by any verb.
Usage example:
-
Retrieve last products liked
-
Retrieve last items seen
-
Retrieve last buys
eb
Run the tests
Tests are made using Jest
npm run test