Quick Start

Implementing Brytelytics at the Client Side

This guide will help you understand how to use client-side libraries for tracking real estate events with Brytelytics. If you want to instead use server-side tracking (recommended for websites), you can access those instructions on the Server-Side Tracking guide.

Introduction

Brytelytics is a real estate analytics service for real estate websites and mobile apps. Real estate companies use it to better understand their online consumers, if they are buyers, renters, or sellers, when and where they are looking to move, what home features they are interested in, and how close they are to needing a real estate agent.

If you are installing Brytelytics into a mobile app or client-side in a website, this guide will help you locate and install the official libraries for your chosen platform.

Select your language at the top of this page

These docs automatically filter examples based on your preferred language. Select the best option for your implementation at the top of this page to ensure you're looking at the correct examples.

Obtaining an API Key

Events are rolled up to an API key and the parent real estate company. Inside the Brytelytics dashboard, brokers can select a specific key, or see all events across the company, even across other vendors that use Brytelytics.

Your Brytecore developer liaison can provide you with an API key for each website or app in which you want to install Brytelytics. If you are a Brytecore Partner, you can create keys via the Brytecore API or through the Vendor Provisioning Dashboard.

Importing the Library

Brytecore provides several official SDKs for client-side implementation, including JavaScript for web, Swift for iOS via CocoaPods, and Java for Android.

The libraries wrap HTTP calls in a brytescore function that can be called from your code whenever an event occurs. You simply include the library in your project, and call brytescore function with the event as a parameter.

Use the examples on the right to learn how to import the proper library based on the platform you are using.

Including the snippet is just the first step! You must still track each triggered event with the brytescore function, as shown in the next section.

All official Brytelytics libraries are open source, and can be found on the Brytecore GitHub page at github.com/brytecore.

The iOS Library

The brytescore-ios library can be added to your iOS application. It is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "BrytescoreAPI"

Initialization

Sets the API key. Generates a new unique session ID. Retrieves the saved user ID, if any.

let _apiManager = BrytescoreAPIManager(apiKey: "YOUR_API_KEY")

The Android Library

The brytescore-android library can be added to your Android application. To install it, clone the brytescore repo and simply add the brytescore folder to your project's directory. Then add the following line to your app's build.gradle:

compile project(path: ':brytescore')

Initialization

Sets the API key. Generates a new unique session ID. Retrieves the saved user ID, if any.

brytescore = new Brytescore(getApplicationContext(), "YOUR_API_KEY");

The JavaScript SDK

Copy and paste this code into your site header, inside the HEAD section of each page. This can usually be performed inside a server-side include or templating engine partial. Replace YOUR_API_KEY with your own key.

<!-- Brytescore -->
<script>
	(function(a,c,g,e,d,f,b){e[d]=e[d]||function(){(e[d].q = e[d].q || []).push( arguments )};e[d].t=1*new Date();
	b=a.getElementsByTagName( c )[0];f=a.createElement(c);f.async=1;f.src=g;b.parentNode.insertBefore(f,b)})
	(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");
</script>
<!-- End Brytescore -->

The snippet asynchronously loads the brytescore.js file from our CDN, which then loads the required rulesets and events (called packages) for your business.

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

The minified brytescore.js file can be downloaded directly from the CDN link below, and you can view the source code on GitHub.

The brytescore Function

Interaction with the Brytelytics 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.

packageName.eventName

Unless the event is a core Brytelytics 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.

/* brytescore function syntax. */

brytescore( 'packageName.eventName', eventDataObject );
/* brytescore function syntax. */

_apiManager.brytescore(property: "packageName.eventName", data: eventDataObject)
/* brytescore function syntax. */

brytescore.brytescore("packageName.eventName", eventDataObject);

Packages Explained

A package is a set of rules for a specific line of business that are used by the Brytelytics algorithms to understand and score user behaviors. The only package included by default is the Brytelytics 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 two files: package.json and schema.json.

File NameDescription
package.jsonA list of events that can be tracked by the API client
schema.jsonThe data definitions for valid events and objects