Lead Booster - Overview

The Lead Booster API works through a small JavaScript snippet installed on your website. The snippet asynchronously loads the brytescore.js file from our CDN, which then loads the required rulesets and events (called packages) for your business.

The snippet allows you to immediately call brytescore events without waiting for the asynchronous load to complete. The code will queue the events until the API is loaded.

Obtaining an API Key

In order to use the snippet, you will need an API key assigned by Brytecore. Please contact your developer liaison for your key.

Analysis of the Snippet

To install the API on your website, you can simply copy the minified snippet into the HEAD section of each page on your website. We recommend the HEAD section in order to begin the asynchronous load as soon as possible in the page load lifetime.

The minified snippet is located on the Quick Start page. The code below is the unminified version, which is only for reference. You can always find the latest version of the unminified snippet on GitHub.

/*	Unminified Brytescore API snippet
	Not recommended for production. Use minified snippet instead. */

(function ( document, script, script_source, window, name, generated_script, calling_script ) {
	'use strict';
	window[name] = window[name] || function() {
		( window[name].q = window[name].q || [] ).push( arguments );
	};
	window[name].t = 1 * new Date();
	calling_script = document.getElementsByTagName( script )[0];
	generated_script = document.createElement( script );
	generated_script.async = 1;
	generated_script.src = script_source;
	calling_script.parentNode.insertBefore( generated_script, calling_script );
})( document, 'script', 'https://cdn.brytecore.com/brytescore.js/brytescore.min.js', window, 'brytescore' );

brytescore( 'setAPIKey', 'YOUR_API_KEY' );
brytescore( 'pageView', {} );
brytescore( "load", "https://cdn.brytecore.com/packages/realestate/package.json" );

The snippet creates a SCRIPT section in your web page that accepts calls to the brytescore() function while asynchronously loading the brytescore.js file from the Brytecore CDN.

The setAPIKey command is required and allows you to pass your API Key to the Brytecore servers during event logging. See the Functions Reference for details on the core functions available in the Lead Booster API library.

The pageView command simply tracks the page view of the person loading the page. There are some optional parameters you can manually pass more details about the page view. See the Core Package Reference for more details about page views and sessions.

The load command loads the real estate package, which contains the valid events and objects that feed into the Brytescore algorithms supporting real estate. See Real Estate Package Reference for more info.

The brytescore Function

Interaction with the Lead Booster API happens via a single global function, brytescore. It takes two parameters, the event to track and an object containing data related to the event. Acceptable properties of the data object are different per event and are validated via the schema that contains the event.

/* Brytescore function syntax. */

brytescore( 'packageName.eventName', eventDataObject );

packageName.eventName

Unless the event is a core Brytescore event, it is always preceded by the package name. For example, a real estate event to track a user viewing a listing would be realestate.viewedListing.

eventDataObject

The eventDataObject is a JSON object matching the schema specific to the package and event. Package schemas are located in the package folder in a file named schema.json. View the schema for the Real Estate package. The API will validate the data you pass with the package schema.

We recommend validating your data from the package schema before pushing your code into production.

Packages Explained

A package is a set of rules for a specific line of business that are used by the Brytescore algorithms to understand and score user behaviors. The only package included by default is the Lead Booster Core Package, which is used to process user sessions, visits, and page views.

Any other package you intend to use must be loaded by the brytescore.load function. This will asynchronously download a package.json file, which is used to define the list of events you can track. View the package.json file for the Real Estate package.

A package includes four files: package.json, schema.json, indicators.json, and queries.json.

File Name Description
package.json A list of events that can be tracked by the API client
schema.json The data definitions for valid events and objects
indicators.json The indicators that train the machine learning algorithms
queries.json The set of queries and aggregates that can be used when querying the data tracked with this package
Indicators and Queries are currently in Beta and not available to API customers.