The Brytelytics 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.
The majority of Brytelytics 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.
Runs the library in local development mode. No data will be sent to the Brytelytics 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.
/* brytescore devMode syntax */
brytescore( "devMode", true );
/* brytescore devMode syntax */
_apiManager.devMode(enabled: true)
/* brytescore devMode syntax */
brytescore.devMode(true);
This function is not available to server-side code. It's specifically a feature of the Brytecore official libraries.
Loads a package. Brytelytics packages are encapsulations of rules, objects, and events that create business rules boundaries for the API when scoring leads and predicting user behaviors.
/* 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")
This function is not necessary for server-side code. It's specifically a feature of the Brytecore official libraries.
Sets your API key. Required to track events.
/* setAPIKey syntax */
brytescore( "setAPIKey", apiKey );
This is done during the initialization process.
This is done during the initialization process.
This function is not necessary for server-side code. It's specifically a feature of the Brytecore official libraries.
A physical or mailing address.
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";
}
A user-submitted data entry form.
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";
}
A geographical coordinate, used to plot locations on a map.
/* 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);
}};
A set of one or more telephone numbers.
/* 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");
}};
An authenticated user account of the website or application.
/* 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");
}};
The authenticated, registeredAccount and updatedUserInfo events help Brytelytics 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.
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.
/* 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);
The user registered an account on your application or website. A registration is the first time a user creates their account. Subsequent logins
/* 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);
The user updated their contact information.
/* 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);
The user viewed a page. This event is tracked by default inside the Brytelytics 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
/* 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);
The user submitted a form via the application or website.
/* 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 are handled internally by the Brytelytics API client and should not be called by your code directly, unless you are writing your own API client.
No examples are given for system events. If you are using an official library, these events are handled automatically.
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.