Events are the pieces of information you wish to track and analyze. Events of the same topic are stored in Collections, which are created on-the-fly as you send your first event. The example below creates a new Collection named Gameplay, but you can specify any name you wish.

We will be pushing a new round event into the Gameplay collection. The event should be in JSON format and it looks like this example.

The Event data below is the JSON representation of the round event.

{
  "game": "The Matrix",
  "user": {
    "id": "194337",
    "username": "itay",
    "country": "Germany"
  },
  "device": {
    "type": "mobile",
    "make": "Apple"
  },
  "rounds": {
    "played": 10,
    "won": 7,
    "lost": 3,
    "duration_sec": 172
  }
}

Copy, modify and paste the cURL statement below into a terminal window. Replace <APPLICATION_URL>, <COLLECTION> and <WRITER_API_TOKEN> with values specific to your application.

curl -X POST -H "Content-Type: application/json" --data-binary "[{
  \"game\":\"The Matrix\",
  \"user\":{\"id\":\"194337\",\"username\":\"itay\",\"country\":\"Germany\"},
  \"device\":{\"type\":\"mobile\",\"make\":\"Apple\"},
  \"rounds\":{\"played\":10,\"won\":7,\"lost\":3,\"duration_sec\":172}
  }]" https://<APPLICATION_URL>/insert/<COLLECTION>?APIToken=<WRITER_API_TOKEN>

A few notes on the above command:

  • -X indicates that we wish to perform an HTTP POST operation.
  • -H adds an application/json content-type header to the request.
  • --data-binary includes the actual JSON payload of the event to push.

The response should look like, depending on your data source provider:

{
    "deleted": 0,
    "errors": 0,
    "inserted": 1,
    "replaced": 0,
    "skipped": 0,
    "unchanged": 0
}

You're done, your event is pushed.

Let's review a few things that happened during this example:

  • First, we sent a REST API request to your Joola application while specifying your application's specific URL, collection and security token.
  • Since the collection did not exist before, Joola created it for you.
  • Joola inserted the event into your collection and it is available for query and analysis.
  • Lastly, you received confirmation on your insert.

Once you receive a response from the server that your event has been pushed, it may take a few seconds before it will appear in query results.