Membrain Beacon - Documentation

Learn more about the benefits and how the Beacon works in this article The Beacon - How it works.

Beacon Demo

To get a better feel for how the Beacon may be deployed and used we provide a simple demo HTML file that you can download and look at that covers all the basic actions supported by the Beacon, including a form that allows you to Identify a visitor with the Beacon.

NOTE: All actions on the demo page, by default, happen against a Demo instance of Membrain and not your own instance.

Beacon Demo Page (right-click, save as to download)

Installation

To get started with the Membrain Beacon the following script needs to be present on the pages you want to track on your website. Do note that the Membrain Beacon uses cookies, which means you should trigger its inclusions only after the website visitor has agreed to any cookie tracking notices that are required in your region.

(function (w, d, u, n) {

var cn = 'MembrainBeaconObjectContext';
w[cn] = w[cn] || { url: u, commands: [] };
w[n] = function (command, data, callback) {

	w[cn].commands.push({ command: command, data: data, callback: callback });
	if (w[cn].ProcessNextCommand) { w[cn].ProcessNextCommand(); }
}

var e = d.createElement('script');
e.src = u + '/Beacon/Get';
e.async = 1;

var firstScript = d.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(e, firstScript);

})(window, document, 'https://YOURDOMAIN.membrain.com/', 'MB');

MB('LogPageView', { url: document.location, name: document.title });

The above code will make the MB function available to you which gives access to several different features.

Note that https://YOURDOMAIN.membrain.com/ in the above code needs to be changed to your actual Membrain domain.

Identifying a Contact ('Identify')

Before tracking can fully work you must Identify a Contact via a cookie stored on their computer. Note that supported calls can be used prior to identifying a contact. When a contact is finally identified any pending actions will be executed automatically.

If the Contact has ever used your /Meet/ calendar or accessed content shared via the Content Hub they will already have been Identified.

To manually Identify a Contact, for example after having someone fill out a form on your website, use the following call on a page with the Beacon installed:

MB('Identify', { name: 'NAME_OF_CONTACT', company: 'NAME_OF_COMPANY', email: 'EMAIL_OF_CONTACT' });

NOTE: that Name, Company, and Email are all required and must be provided by you.

Logging a Page View ('LogPageView')

Logging when a Contact visits a specific page is the most basic use case and is thus included by default in the code to include on your site. If your website acts as a Single Page Application you may manually trigger the LogPageView command as needed using the following call:

MB('LogPageView', { url: 'YOUR_URL_HERE', name: 'YOUR_PAGE_NAME_HERE' });

NOTE: Do not forget to replace YOUR_URL_HERE and YOUR_PAGE_NAME_HERE with the appropriate values. The logging will not work if not provided with a valid URL.

Logging a Page Event ('LogPageEvent')

In addition to logging page views, it is also possible to log simple events. Ex: 'Completed Purchase', 'Signed-Up for Newsletter'.

MB('LogPageEvent', { name: 'YOUR_EVENT_NAME_HERE' });

Getting the Identity of a visitor ('GetIdentity')

You can access the Identity of the current visitor via the GetIdentity call. If the visitor has not been Identified, the result will be null.

If the Identity is known, you will get an object as follows: { firstName: 'FIRST_NAME', lastName: 'LAST_NAME', company: 'COMPANY', email: 'EMAIL' }.

MB('GetIdentity', null, YOUR_ON_SUCCESS_CALLBACK_FUNCTION);

Clearing the Identity of a visitor ('Unidentify')

You can disconnect the Identity of the current visitor by removing the tracking cookie with the Unidentify command. This can be especially useful for testing.

MB('Unidentify', null, YOUR_ON_SUCCESS_CALLBACK_FUNCTION);

Creating a Prospect ('CreateProspect')

You can create a new Prospect for the current visitor in a specific process. Typically you'd call this only after calling Identify.

MB('CreateProspect', { process: 'NAME_OR_ID_OF_YOUR_CAMPAIGN' }, YOUR_ON_SUCCESS_CALLBACK_FUNCTION);

NOTE: you can also provide custom field information when creating a Prospect, see below

Creating a Sales Project ('CreateOpportunity')

You can create a new Sales Project for the current visitor in a specific process. Typically you'd call this only after calling Identify.

MB('CreateOpportunity', { process: 'NAME_OR_ID_OF_YOUR_CAMPAIGN' }, YOUR_ON_SUCCESS_CALLBACK_FUNCTION);

NOTE: you can also provide custom field information when creating a Sales Project, see below

Creating an Activity ('CreateActivity')

You can create a new Activity for the current visitor with a specific activity type and contents. Typically you would call this only after calling Identify.

MB('CreateActivity', { type: 'NAME_OR_ID_OF_ACTIVITY_TYPE', contents: 'ACTIVITY_CONTENTS' }, YOUR_ON_SUCCESS_CALLBACK_FUNCTION);

NOTE: you can also provide custom field information when creating an Activity, see below

Setting Custom Fields When Using CreateProspect, CreateOpportunity or CreateActivity

You can also set custom field information when using either CreateProspect, CreateOpportunity or CreateActivity. To do so you may optionally provide any number of additional parameters with the following pattern:

MB('ACTUAL_COMMAND', { customfield_name_of_field_all_lower: 'VALUE', other parameters }, YOUR_ON_SUCCESS_CALLBACK_FUNCTION);

The custom field name must be provided withthe 'customfield_' prefix + the actual field name in all lower case, with any spaces replaced by an _ character. In terms of supported field types, you can set Text, Number, Single-Select & Multi-Select fields. The fields are only set if a new item is created.

When setting a Single or Multi-Select field, provide the options either with the corresponding GUID OR more commonly by an exactly matching name. For Multi-Select fields, seperate options with a | (pipe) character.