2.1.1 • Published 6 years ago

primednodejs v2.1.1

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
6 years ago

primednodejs

Create a personalized web application that is unique and relevant for each and every user with Primed.io.

Use

Installation

npm install primednodejs

Example

var PRIMEDIO = require('primednodejs');

// Instantiate PRIMEDIO, api_url, public key
// and secret key are provided by PrimedIO
var pio = new PRIMEDIO({
	api_url: "https://primed.io",
	public_key: 'xxxxxxxxxxxxxxxxxxxxxxxx', 
	secret_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
});

// Perform the personalise call,
// which returns a 'promise'
var promise = pio.personalise({
	campaign: 'frontpage.article.bottom',
	signals: { 
		'article_id': '2578346', 
		'tod-dow': 'Fri_15-18'
	},
	limit_results: 10
});

// Deal with the results as they are returned
// by Primed. 
promise.then(function(response) {
	// 'response' is a wrapper object,
	// calling 'response.all()' returns
	// the list of results which can then be
	// used to render the page
	var results = response.all();
	
	// simulate a click -- 'conversion'
	var clicked = response.first();

	// mark the clicked result as converted
	// by using the `.uuid` property
	pio.convert(clicked.uuid);
}).catch(function (err) {
	console.log('Personalize failed: ' + err);
});

// Converting clicks.
// Each result comes with a guaranteed
// random UUID (Result UUID). This UUID can be sent 
// back to PrimedIO to mark a result as having been
// converted. This in turn allows the system
// to evaluate the performance (as CTR) of the
// underlying Model (blend).
pio.convert({
	ruuid: "df3870dc-b277-11e7-abc4-cec278b6b50a"
}); 

Initialization

PRIMED.init({
	api_url: "https://primed.io",
	public_key: "xxxxxxxxxxxxxxxxxxxxxxxx",
	secret_key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
argtyperequireddescriptionexample
api_urlstringYessets the Primed.io API url`"https://primed.io"
public_keystringYessets the public key"xxxxxxxxxxxxxxxxxxxxxxxx"
secret_keystringYessets the secret key"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Personalisation

Personalisation requires at least a campaign key (NB, this is not the campaign name), e.g. frontpage.recommendations.

pio.personalize({
	campaign: "frontpage.recommendations",
	signals: { itemId: '2503001'},
	limit: 5,
	abvariant: 'A'
});
argtyperequireddescriptionexample
campaignstringYescampaign key for which personalisation is retrievedfrontpage.recommendations
signalsdictionaryNo (defaults to {})key, value pairs of signals (itemId currently being viewed, deviceId, location, etc.){itemId: '1234', userId: 'xyz'}
limitintegerNo (defaults to 5)number of desired results10
abvariantstringNo (defaults to WRANDOM assignment)specify A/B variant for which to retrieve personalisation__CONTROL__

Conversion

Upon successful personalisation, a list of results will be returned. Each result will contain a variable payload: the idea here is that PrimedIO is generic and supports freeform Targets, which can be item ID's (usually used in lookups after the personalize call), URL's, Boolean values, and any combination of these. Additionally, each result will contain a unique RUUID (Result UUID), randomly generated for this particular call and Target. It is used to track the conversion of this particular outcome, which we use to identify which of the A/B variants performed best. Conversion is also generic, but generally we can associate this with clicking a particular outcome. In order for PrimedIO to register this feedback, another call needs to be made upon conversion. This in turn allows the system to evaluate the performance (as CTR) of the underlying Model (blend).

pio.convert({
	ruuid: "6d2e36d1-1b58-4fbc-bea8-868e3ec11c87",
	data: { heartbeat: 0.1 }
});
argtyperequireddescriptionexample
ruuidstringYesruuid for which to register conversion"6d2e36d1-1b58-4fbc-bea8-868e3ec11c87"
datadictionaryNofreeform data payload{ heartbeat: 0.1 }
2.1.1

6 years ago

2.1.0

7 years ago

2.0.2

7 years ago

0.0.19

8 years ago

0.0.18

8 years ago