Data API

Fanplayr's data API is a simple javascript array which can be used to store and send information to the Fanplayr Platform. It can be used alongside the standard Fanplayr integration to track additional information in your store.

Getting Started

To set up the data API, add the following snippet to the head of your page (or elsewhere above the User Tracking snippet):

<script>
fanplayr_api = [];
</script>

Examples

Tracking additional page properties

In the following example, two additional properties named brand and color are captured along with the standard information Fanplayr tracks for page views.

The special _type property informs Fanplayr that the information should be stored with the page view.

<script>
fanplayr_api.push({
  "_type": "page.data",
  "brand": "Super",
  "color": "red"
});
</script>

Page tracking callback

The following example defines a Javascript callback to be invoked by Fanplayr whenever it tracks a page view.

This mechanism could be used to implement special logic in the browser that reacts as users fall into predefined segments. E.g. Open a third-party chat widget when users fall into a specific Fanplayr segment.

<script>
fanplayr_api.push({
  "_type": "onPageView",
  "callback": function (event) {
    // Called after Fanplayr tracks each page view.
    // `event.segments` is an array of any segment tags the user fell into for the tracked page.
  }
});
</script>

results matching ""

    No results matching ""