Quick Start

Core Objects and Events

The Lead Booster API includes a base set of functions that are always available, no matter which packages are loaded. These are cross-industry, common behaviors supported by the API.

The API uses the concept of JSON Schemas extensively. For more information about how JSON Schemas work, and how to validate your data against a schema, visit json-schema.org.

Analytics Package

The majority of Lead Booster API events and related objects are defined in the Analytics Schema. These events handle all common activity a user performs on a app or website, such as authentication and page/screen views.

Basic Functions

There are three core functions unrelated to event tracking, devMode, load and setAPIKey. These are the only functions not validated by a JSON schema.

devMode

Runs the library in local development mode. No data will be sent to the Lead Booster Analytics API. Each time the brytescore function is called, it will log the data object to your console. You can copy and paste this object into a JSON validator to catch syntax errors.

enabled
boolean
required
Set to true to enable devMode. To disable devMode (default), omit this function entirely.
/* brytescore devMode syntax */

brytescore( "devMode", true );
/* brytescore devMode syntax */

_apiManager.devMode(enabled: true)
/* brytescore devMode syntax */

brytescore.devMode(true);

load

Loads a package. Lead Booster Analytics packages are encapsulations of rules, objects, and events that create business rules boundaries for the API when scoring leads and predicting user behaviors.

packageURL
string
required
The URL of the package to load.
/* brytescore load syntax */

var packageURL = "https://cdn.brytecore.com/packages/realestate/package.json";

brytescore( "load", packageURL );
/* brytescore load syntax */

// Load real estate package
brytescore.load("realestate");
/* brytescore load syntax */

// Load real estate package
_apiManager.load(package: "realestate")

setAPIKey

Sets your API key. Required to track events.

apiKey
string
required
Your Lead Booster API key for this website or app
/* setAPIKey syntax */

brytescore( "setAPIKey", apiKey );

This is done during the initialization process.

This is done during the initialization process.

Basic Schemas

The Lead Booster API includes a basic set of schemas that make re-use of common objects easy. These are exposed as data types in the event schemas.

address

A physical or mailing address.

streetAddress
string
The house number and street address
streetAddress2
string
The apartment, suite, or other secondary address
city
string
The city or municipality part of the address
stateProvince
string
The state or province
zipPostal
string
The postal or zip code
country
string
The name of the country

This object is often used to extend other objects that include a physical location, such as real estate listing addresses and user home addresses.

/* address example */

var address = {
	"streetAddress": "84 Rainey Street",
	"city": "Arlen",
	"stateProvince": "TX",
	"zipPostal": "75040"
}
// Address example

struct Address {
	var streetAddress = "84 Rainey Street"
	var city = "Arlen"
	var stateProvince = "TX"
	var zipPostal = "75040"
}
// Address example

public class Address {
	String streetAddress = "84 Rainey Street";
	String city = "Arlen";
	String stateProvince = "TX";
	String zipPostal = "75040";
}

form

A user-submitted data entry form.

fromEmail
string
The email address of the sender
fromName
string
The name of the sender
fromTelephone
telephone
The telephone number(s) of the sender
message
string
The contents of the message provided by the sender
name
string
The name of the form (ex: contact, about, etc)
subject
string
The subject of the form or email
toEmail
string
The email address of the person to which the form was sent
toName
string
The name of the person to which the form was sent

Use this basic form object whenever a form is submitted that is not included in your specific package.

For example, use this object in the submittedForm event when a user submits a "Contact Us" form on a real estate site, but not when a user submits a listing inquiry (use realestate.requestedInfo instead, in that case).

/* form example */

var form = {
	"fromEmail": "info@ivankatrump.com",
	"fromName": "Ivanka Trump",
	"fromTelephone": {
		"mobile": "212.555.0001",
		"home": "212-555-0100"
	},
	"message": "Real estate is my day job. But it consumes my nights and weekends, too.",
	"name": "testimonial-request-form",
	"subject": "Thoughts on real estate",
	"toEmail": "agent@yourcompany.com",
	"toName": "Suzie Agent"
}
// form example

struct Form {
	let fromEmail = "info@ivankatrump.com"
	let fromName = "Ivanka Trump"
	let fromTelephone = [
		"mobile": 212-555-0001",
		"home": "212-555-0100"
	]
	let message = "Real estate is my day job. But it consumes my nights and weekends, too."
	let name = "testimonial-request-form"
	let subject = "Thoughts on real estate"
	let toEmail = "agent@yourcompany.com"
	let toName = "Suzie Agent"
}
// form example

public class Form {
	String fromEmail = "info@ivankatrump.com";
	String fromName = "Ivanka Trump";
	HashMap<String, String> fromTelephone = new HashMap<String, String> () {{
		put("mobile", "212-555-0001");
		put("home", "212-555-0100");
	}};
	String message = "75040";
	String name = "testimonal-request-form";
	String subject = "Thoughts on real estate";
	String toEmail = "agent@yourcompany.com";
	String toName = "Suzie Agent";
}

geo

A geographical coordinate, used to plot locations on a map.

latitude
number
required
The latitude, in decimal
longitude
number
required
The longitude, in decimal
/* geo example */

var latLng = {
	"latitude": 33.9127722,
	"longitude": -84.3601298
}
/* geo example */

let latLng = [
	"latitude": 33.9127722,
	"longitude": -84.3601298
]
/* geo example */

HashMap<String, Float> latLng = new HashMap<String, Float>() {{
	put("latitude", 33.9127722);
	put("longitude", -84.3601298);
}};

telephone

A set of one or more telephone numbers.

mobile
string
A mobile telephone number
home
string
home telephone number
work
string
A work telephone number
fax
string
A fax number
direct
string
A work direct line telephone number
/* telephone example */

var telephone = {
	"mobile": "636-KL5-3226",
	"home": "(212) 555-2368"
}
/* telephone example */

let telephone = [
	"mobile": "636-KL5-3226",
	"home": "(212) 555-2368"
]
/* telephone example */

HashMap<String, String> telephone = new HashMap<String, String>() {{
	put("mobile", "636-KL5-3226");
	put("home", "(212) 555-2368");
}};

userAccount

An authenticated user account of the website or application.

id
string
The user id of the account
emailAddress
string
The email address associated with the user account
firstName
string
The first name of the user
lastName
string
The last name of the user
/* userAccount example */

var userAccount = {
	"id": "42",
	"emailAddress": "fordprefect@milkywayguides101.com",
	"firstName": "Ford",
	"lastName": "Prefect"
}
/* userAccount example */

let userAccount = [
	"id": "42",
	"emailAddress": "fordprefect@milkywayguides101.com",
	"firstName": "Ford",
	"lastName": "Prefect"
]
/* userAccount example */

HashMap<String, Object> userAccount = new HashMap<String, Object>() {{
	put("id", "42");
	put("emailAddress", "fordprefect@milkywayguides101.com");
	put("firstName", "Ford");
	put("lastName", "Prefect");
}};

Authentication Events

The authenticated, registeredAccount and updatedUserInfo events help Lead Booster understand who your users are by providing their contact information and associated user account data. It is important to capture all of these events when they happen in your system in order to provide the lead contact information to the CRM, which in turn provides this information to your agents.

authenticated

The user logged into your application or website.

Please note that your must call the authenticated event in ALL situations where a user is signed into your app or website, including automatically signing in from a cookie, or via a third party, like Facebook or Gmail.

userAccount
userAccount
The details of the user account.
address
address
The address provided by the user.
telephone
telephone
The telephone number(s) provided by the user.
isLead
boolean
The registered user is a lead. Sometimes a user who registers on your app or site is not a lead (such as a test account or staff member).
userClassification
string
Your classification of this user. Optionally used to segment your leads.
dateRegistered
timestamp
The date the user registered in the system. Defaults to current date and time. (ISO 8601 String)
/* authenticated example */

// Build nested objects
var userAccount = {
	"id": "75",
	"emailAddress": "gump@bgcfood99.com",
	"firstName": "Bubba",
	"lastName": "Gump"
}

var address = {
	"city": "Savannah"
}

var telephone = {
	"home": "912-555-0840"
}

// Build the data object
var data = {
	"userAccount": userAccount,
	"address": address,
	"telephone": telephone,
	"isLead": true,
	"userClassification": "Google Lead",
	"dateRegistered": ""
}

// Call the event
brytescore( "authenticated", data );
/* authenticated example */

// Build the data object
var data = [
	"userAccount": [
		"id": 75,
		"emailAddress": "gump@bgcfood99.com",
		"firstName": "Bubba",
		"lastName": "Gump"
	],
	"address": [
		"city": "Savannah"
	],
	"telephone": [
		"home": "912-555-0840"
	],
	"isLead": true,
	"userClassification": "Google Lead",
	"dateRegistered": ""
]

// Call the event
_apiManager.authenticated(data: data)
/* authenticated example */

// Build nested objects
HashMap<String, Object> userAccount = new HashMap<String, Object>() {{
	put("id", 75);
	put("emailAddress", "gump@bgcfood99.com");
	put("firstName", "Bubba");
	put("lastName", "Gump");
}};

HashMap<String, String> address = new HashMap<String, String>() {{
	put("city", "Savannah");
}};

HashMap<String, String> telephone = new HashMap<String, String>() {{
	put("home", "912-555-0840");
}};

// Build the data object
HashMap<String, Object> data = new HashMap<String, Object>() {{
	put("userAccount", userAccount);
	put("address", address);
	put("telephone", telephone);
	put("isLead", true);
	put("userClassification", "Google Lead");
	put("dateRegistered", "");
}};

// Call the event
brytescore.authenticated(data);

registeredAccount

The user registered an account on your application or website. A registration is the first time a user creates their account. Subsequent logins

userAccount
userAccount
The details of the user account.
address
address
The address provided by the user.
telephone
telephone
The telephone number(s) provided by the user.
isLead
boolean
The registered user is a lead. Sometimes a user who registers on your app or site is not a lead (such as a test account or staff member). Defaults to true.
userClassification
string
Your classification of this user. Optionally used to segment your leads.
dateRegistered
timestamp
The date the user registered in the system. Defaults to current date and time.
/* registeredAccount example */

var userAccount = {
	"id": "5",
	"emailAddress": "hi@my-azquints.net",
	"firstName": "H.I.",
	"lastName": "McDunnough"
}

var address = {
	"city": "Raising",
	"stateProvince": "AZ"
}

var telephone = {
	"home": "480.555.6162"
}

var data = {
	"userAccount": userAccount,
	"address": address,
	"telephone": telephone,
	"isLead": true,
	"userClassification": "Google Lead"
}

// dateRegistered will default to now.

brytescore( "registeredAccount", data );
/* registeredAccount example */

let data = [
	"userAccount": [
		"id": 5,
		"emailAddress": "hi@my-azquints.net",
		"firstName": "H.I.",
		"lastName": "McDunnough"
	],
	"address": [
		"city": "Raising",
		"stateProvince": "AZ"
	],
	"telephone": [
		"home": "480.555.6162"
	],
	"isLead": true,
	"userClassification": "Google Lead"
]

// dateRegistered will default to now.

_apiManager.registeredAccount(data: data)
/* registeredAccount example */

HashMap<String, Object> userAccount = new HashMap<String, Object>() {{
	put("id", 5);
	put("emailAddress", "hi@my-azquints.net");
	put("firstName", "H.I.");
	put("lastName", "McDunnough");
}};

HashMap<String, String> address = new HashMap<String, String>() {{
	put("city": "Raising");
	put("stateProvince": "AZ");
}};

HashMap<String, String> telephone = new HashMap<String, String>() {{
	put("home", "480.555.6162");
}};

HashMap<String, Object> data = new HashMap<String, Object>() {{
	put("userAccount", userAccount);
	put("address", address);
	put("telephone", telephone);
	put("isLead", true);
	put("userClassification", "Google Lead");
}};

// dateRegistered will default to now.

brytescore.registeredAccount(data);

updatedUserInfo

The user updated their contact information.

userAccount
userAccount
The details of the user account.
address
address
The address provided by the user.
telephone
telephone
The telephone number(s) provided by the user.
/* updatedUserInfo example */

var userAccount = {
	"id": "66",
	"emailAddress": "chewie@awwwrrrawwhh.com",
	"firstName": "Chewbacca",
	"lastName": "Rahhggaahh Urughaghhh"
}

var address = {
	"streetAddress": "298-B24DC Wroshyr Tr",
	"city": "Thikkiiana",
	"stateProvince": "Woolwarricca",
	"postalCode": "P85D-2",
	"country": "Kashyyyk"
}

var telephone = {
	"home": "11381138",
	"mobile": "5041977"
}

var data = {
	"userAccount": userAccount,
	"address": address,
	"telephone": telephone
}

// dateRegistered will default to now.

brytescore( "updatedUserInfo", data );
/* updatedUserInfo example */

let data = [
	"userAccount": [
		"id": 66,
		"emailAddress": "chewie@awwwrrrawwhh.com",
		"firstName": "Chewbacca",
		"lastName": "Rahhggaahh Urughaghhh"
	],
	"address": [
		"streetAddress": "298-B24DC Wroshyr Tr",
		"city": "Thikkiiana",
		"stateProvince": "Woolwarricca",
		"postalCode": "P85D-2",
		"country": "Kashyyyk"
	],
	"telephone": [
		"home": "11381138",
		"mobile": "5041977"
	]
]

// dateRegistered will default to now.

_apiManager.updatedUserInfo(data: data)
/* updatedUserInfo example */

HashMap<String, Object> userAccount = new HashMap<String, Object>() {{
	put("id", 66);
	put("emailAddress", "chewie@awwwrrrawwhh.com");
	put("firstName", "Chewbacca");
	put("lastName", "Rahhggaahh Urughaghhh");
}};

HashMap<String, String> address = new HashMap<String, String>() {{
	put("streetAddress", "298-B24DC Wroshyr Tr");
	put("city", "Thikkiiana");
	put("stateProvince", "Woolwarricca");
	put("postalCode", "P85D-2");
	put("country", "Kashyyyk");
}};

HashMap<String, String> address = new HashMap<String, String>() {{
	put("home", "11381138");
	put("mobile", "5041977");
}};

HashMap<String, Object> data = new HashMap<String, Object>() {{
	put("userAccount": userAccount);
	put("address": address);
	put("telephone": telephone);
}};

// dateRegistered will default to now.

brytescore.updatedUserInfo(data);

Analytics Events

pageView

The user viewed a page. This event is tracked by default inside the Lead Booster Analytics API snippet. Whenever the Analytics library detects a URL change, a new page view is automatically logged.

The pageview event supports Google Analytics UTM codes. You can provide these manually, or they will be automatically tracked if omitted from the event but present in the URL. Learn more about UTM codes on the Google Analytics URL Builder help page

referrer
string
Override the referring page.
pageTitle
string
Override the title of the page.
pageURL
string
Override the URL of the page.
utmSource
string
Where the campaign originated.
utmMedium
string
The campaign medium, for example email or cost-per-click.
utmTerm
string
The search term used by the campaign.
utmContent
string
Used to differentiate different ads landing on the same page.
utmCampaign
string
The name of your campaign.
/* pageView example */

// Call the event with default and auto-determined values.
brytescore( "pageView", {} );
/* pageView example */

// Call the event with default and auto-determined values.
_apiManager.pageView(data: [:])
/* pageView example */

// Call the event with default and auto-determined values.
HashMap<String, Object> pageViewData = new HashMap<String, Object>();
pageViewData.put("test_key", "test_data");

brytescore.pageView(pageViewData);

submittedForm

The user submitted a form via the application or website.

form
form
required
The details of the form submitted.
/* submittedForm example */

// Create the form object
var form = {
	"fromEmail": "george@bagels1964.com",
	"fromName": "George Hairyson",
	"fromTelephone": {
		"home": "0843 850 2090"
	},
	"message": "Hi my name is George and I'm looking for an agent to help me sell my home in London.",
	"name": "contact-us",
	"subject": "looking for an agent",
	"toEmail": "info@mycompany.com"
}

// Call the event with the data object containing the form.
brytescore( "submittedForm", { "form": form } );

System Events

System events are handled internally by the Lead Booster Analytics API client and should not be called by your code directly.

No examples are given for system events. If you are using an official library, these events are handled automatically.

brytescoreUUIDCreated

Tracks when the system creates a tracking cookie on the user's machine to track behavior of anonymous users, which can later be tied to an authenticated user with one of the Authentication events.

heartBeat

Tracks how long the user remains active on your app or website. This is used to calculate session and page view lengths. Heartbeats trigger every 15 seconds and cease after 30 minutes of inactivity.

sessionStarted

Tracks when a new user session is started. User activity is generally grouped and reported by session.