Accesssing user concurrency values from your app

How to access concurrency information in your app

Sometimes you might want to know how many people are in your app at one time.

There are two way of doing this: either via Control API which requires server-side scripting or by creating an invisible Poll Element running in the platform.

1. Via The Control API

  1. Extend your App Spec with a new field to store concurrency number. This can be Event level field or Element level field

  2. Use Control API to pull concurrency data from the platform

  3. Use Control API to update the field created in #1 with concurrency number received in #2

  4. Field update will automatically generate event data republishing if the field belongs to the event or element republishing if the field belongs to the element and the element is already published.

  5. The client app receives the concurrency number from event or element field

Do not call Control API from your app Control API must not be called from the client app. Only server-side integration is supported.

Do not poll frequently Control API call to fetch concurrency must not be made more frequently than once a minute.

To fetch current concurrency you would use this call:

curl -H "Authorization: Bearer Yx3_Pnrdy4A46tdvfMrKEEQuczDyAUyh" --request GET --url

The response will contain:

  "included": [
      "id": "df60a378-f9df-4e13-94d1-a2913fa3",
      "type": "stats",
      "attributes": {
        "interactions": 0,
        "peak_concurrency": 1,
        "current_concurrency": 1,
        "unique_users": 1,
        "average_session_length": 0,
        "elements_count": 0

Full documentation is here: Get event

2. Via an 'invisible' Poll Element

Let's say you publish a sequence of 10 trivia elements and before each one you want to display a number of connected users. This is how you can do it with a special poll:

  1. Publish a poll with 10 options

  2. Do not display this poll to end user

  3. Get the client app to automatically vote for an option which corresponds to upcoming trivia. For example if no trivia has yet been published then vote for the first option, if trivia #2 just finished - vote for the third option.

  4. The app receives voting results for the special poll and knowing what next trivia is expected it can get the number of votes for corresponding poll option and treat that number as the number of playing users.