Custom API
Last updated
Last updated
We may not yet support your platform for getting data into Fanplayr 360, so we offer a powerful API to work directly with our system to add data.
You can use the Custom API to send data from a server, or a mobile app. The options a limitless.
The uses exactly the same calls under the hood.
Once you have created a before starting, to get a WRITE_KEY and ENDPOINT which you can then use to send data to Fanplayr 360.
Calling the API is as simple as making an HTTPS
request with the following details:
URL: https://<ENDPOINT>/v1/collect
Method: POST
Headers
content-type: application/json
x-api-key: <WRITE_KEY>
Body: A JSON string containing an array of Messages.
The API can only handle messages of ~250kb, so we calling the API with no more than 20 Messages in one call.
Each message you send to Fanplayr 360 needs to contain a basic set of data.
writeKey - The WRITE_KEY that is sent through in the x-api-key
must also be supplied here.
type - The type of the message.
The basic message structure may or may not include context
, properties
, identities
and operations
depending on the type
being sent.
context - can be used in any message type
properties - should only be used in track
or page
type
identities - should only be used in identify
type
operations - should only be used in userDataOps
and consent
type
Context is used to track information about the page, or screen, the user is on, and their IP address for location, and userAgent to track browser or device type.
page
url - the URL of the page, if tracking on a website.
referrer - the URL of the referring page, if tracking on a website.
title - the page title of the website or app screen.
Identities are key / value pairs that let the system know how to identify and merge users and sessions. This should only be provided for the message type identify
.
Operations should only be used with the userDataOps
and consent
type messages. The properties supported are different for each.
Read on to understand how to use each message type, along with examples.
messageId - Every message you send must include a unique identifier. We suggest using a , or .
timestamp - The time the event happened in format and UTC time zone ie "2023-01-23T15:34:48Z".
userId - A unique identifier for this user. If the same userId
is supplied in a different session the messages will be treated as if they were from the same user. This is separate from using identify
calls.
sessionId - A unique identifier for a session. See for more details.
pageId - A unique identifier for the current page / screen view. This is used to tie events together. See .
type - a string representing the page. Any value can be used here, but some values will add functionality - see . Can also be used to represent "screens" in a mobile app.
ipAddress - the IP address of the users device, or the server / device that this message was sent from. It is used to such as $country
.
userAgent - the User Agent string from a browser, or defined for a device type such as a mobile phone. It is used to such as $device
.
Properties are any key / value pair, or , which you want to track along with the event. This should only be used with track
or page
type Messages.
The key
for a property can be any string value. It is a suggestion to not start the value with a "$" as this may override . It may also be good practice to use either camel-case keys such as "myKeyName", and stay away from non-ASCII characters as some systems you export data to may otherwise have problems.