Documentation

API JavaScript

Our JavaScript API is the most commonly used API and also the most flexible and robust and gets updated very frequently.

To start with this API, please ensure that you have read our getting started guide and installed your application script on your website as indicated.

Your script is asynchronous so it will have no impact on the speed or performance of your website, even if it becomes unavailable or slows down drastically.

The API exposes an array called _fxm.events that will be your primary means of sending us requests, the events array is independent and can be created and populated before your script loads and the data will simply queue until its handled by the JavaScript API.

It supports the following methods which are explained below in details (setPerson, setVisit, setPage, recordEvent, onFormSubmit, onVisible, onClick & onHover).

Using the API is very simple. Here is the format

<script type="text/javascript">
_fxm.events.push([*method Name, *Event Name, *EventValue, *Event Attributes], *callBack Function);
</script>

setPerson

This method is used to update or specify the identity of the current person that is using your website, note that if you don’t specify who they are, we will automatically generate the required fields. ID is a required field for everyone that visits your website.

<script type="text/javascript">
_fxm.events.push(['setPerson', { id: 'john@doe.com', firstName: 'John', lastName: 'Doe'}]);
</script>

setVisit

This method should be used to update specific details about this visit such as channel attribution, referrer, etc.

<script type="text/javascript">
_fxm.events.push(['setVisit', { id: 'TthTHTNQf3VezXoEUscNtx8dqa4ZP0Z5', channel: 'Search', keywords: 'awesome shoes'}]);
</script>

setPage

If you would like to track page level details and you would like to provide yours then you can override the defaults by using this method, otherwise, we will populate with the actual values as derived from the JavaScript document object.

<script type="text/javascript">
_fxm.events.push(['setPage', { url: 'http://coolwebsite.com', referringUrl: 'http://google.com/?s=awesome shoes', title: 'these awesome shoes'}]);
</script>

recordEvent

The recordEvent method is the most basic method of the JavaScript API and also the most critical and as its name states, this method is responsible for recording events.

<script type="text/javascript">
// Record a simple event called page view
_fxm.events.push(['recordEvent', 'Page View']);
// Record a more complex event with attributes
_fxm.events.push(['recordEvent', 'Purchased Item', 19.99, { SKU: '90841'}]);
</script>

onFormSubmit

Tracking when you users submit a form is also possible with this API and this method allows you to do just that. Once a user submits the specified form or forms, our API will intercept, collect and record an event and then let the form continue its course of action.

<script type="text/javascript">
_fxm.events.push(['onFormSubmit', 'formid', 'event name', { url: document.location}]);
</script>

onVisible

Impression tracking can be very useful - did this person see a specific element? The onVisible method records an event once the page loads and it contains one of more of the specified element. It could be used to track which of your banner variations led to a conversion and more.

<script type="text/javascript">
_fxm.events.push(['onVisible', 'element id', 'event name', { name: 'Banner 1'}]);
</script>

onClick

Tracking clicks are essential to any web business, knowing when and what your users click on provides very granular information that can be used to optimize your website and increase conversion.

<script type="text/javascript">
_fxm.events.push(['onClick', 'element id', 'event name', { color: 'Red'}]);
</script>

onHover

If you have a popup that becomes visible on mouse over or something of that nature then the API’s onHover method is the most appropriate to use for tracking. Using onHover, an event will be recorded once the mouse over event of that element is triggered.

<script type="text/javascript">
_fxm.events.push(['onHover', 'element id', 'event name', { PopupName: 'John Doe Profile'}]);
</script>


blog comments powered by Disqus
Register Now