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
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.
This method should be used to update specific details about this visit such as channel attribution, referrer, etc.
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.
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.
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.
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.
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.
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.
