Location tracking

Location tracking APIs let you retrieve current and last known user location. This data can be used to construct location history for a guest while they are inside the venue. This guide covers location tracking functionality from a mobile application perspective.

This guide assumes that a device has already been registered and that the user has been created. See the Register user devices guide for information on registering a device and obtaining an appUserId.

Reporting location data

The accesso Guest Experience platform uses a combination of GPS, Bluetooth, WiFi, and native mobile OS (Android or iOS) location services to pinpoint and track the location of a user device in relation to a venue.

Location information for a user device is reported through a POST to the /rest/user/device endpoint with location coordinates provided by the device’s GPS:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
curl -i -X POST \
  https://api.{region}.te2.io/rest/user/device \
    -H 'Authorization: Bearer {token}' \
    -H 'Content-Type: application/json' \
    -d '{
            "appUserId": "{appUserId}",
            "appId": "{appId}",
            "userId": "{userId}",
            "platform": "{platform}",
            "pushDeviceToken": "{pushDeviceToken}",
            "location": {
                "lat": 32.874624,
                "lon": -117.206651,
                "horizontalAccuracy": 65
            }
        }'

This will report user device {appUserId} at location (32.87462,-117.206651), with a horizontalAccuracy of 65 meters or better. The platform will then use the appId to determine if this location corresponds to any known venues for this application, and will trigger venue entry and exit events, depending on the current and last known location for this user device.

Determining venue entry and exit

The main mechanism for location tracking is the venue geofence, which is defined using a central latitude, longitude point and radius.

User location is only tracked while the guest is within the venue geofence. Although location updates can be retrieved while users are outside of the venue, this data is not tracked or saved by the platform in any way.

Latest venue data is retrieved by the mobile app using a GET to the /api/v1/public/venues/{venueId} endpoint.

A successful response includes the current venue location information, which is calculated from the geofence boundary.

The reponse also includes a JSON array of all geofences associated with the venue. For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  "geofences": [
    {
      "id": "{fenceId}",
      "venueId": "{venueId}",
      "name": "{name}",
      "label": "{label}",
      "radius": 375,
      "center": {
        "horizontalAccuracy": 5,
        "locationSource": "DEVICE",
        "lat": 32.874624,
        "lon": -117.206651,
      },
    }
  ]

(Full venue response can be found in the Venue API.)

The mobile app sets and tracks these geofences (using the center point with radius) and can determine whether the user device has crossed (breached) any of the tracked geofence boundaries.

Geofence breach events are reported by the user device to the platform using a POST to the /rest/user/device endpoint:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
curl -i -X POST \
  'https://api.{region}.te2.io/rest/user/device?event=ENTER&fenceId=FENCE_123&locationSource=DEVICE' \
    -H 'Authorization: Bearer {token}' \
    -H 'Content-Type: application/json' \
    -d '{
            "appUserId": "{appUserId}",
            "appId": "{appId}",
            "userId": "{userId}",
            "platform": "{platform}",
            "pushDeviceToken": "{pushDeviceToken}",
            "location": {
                "lat": 32.874624,
                "lon": -117.206651,
                "horizontalAccuracy": 65,
                "locationSource": "DEVICE"
            },
            "appVersion": "1.23",
            "label": "Bob's phone",
            "tags": {
                "foo": "bar",
                "baz": "boo"
            },
            "ipAddress": "127.0.0.1",
            "ssid": "MyVenueWifiNetworkName",
            "bssid": "MyVenueWifiBSSID",
            "timestamp": 1561043804000
        }'

In the above request, we can see every field, query string parameter, and header that is considered by the device update endpoint.

The fields introduced here are optional except when needing to inform of very specific kinds of updates (such as registration with a wireless network).

The fields introduced here include:

Tracking location within the venue

Once a user is reported to be inside the venue geofence, location updates can be retrieved and tracked using the device’s native location services.

If GPS is not enabled for the mobile device (and/or location permissions have not been granted to the app), user location can also be inferred through the following:

Additionally, if the mobile device has Bluetooth turned on, location can be inferred while in the venue through beacon pings. Beacons are Bluetooth, low-energy (BLE) devices placed by accesso throughout the venue. Each device has associated latitude, longitude coordinates, and these defined coordinates can provide general user location updates.

Mobile apps can discover beacon regions using a GET to the rest/venue/{venueId}/beacon/regions endpoint.

A successful 200 response returns an array of beacon regions within the stated venue that the app should monitor:

1
2
3
4
5
6
7
8
9
10
[
 {
  "proximityUUID": "{UUID}",
  "major": 123
 },
 {
  "proximityUUID": "{UUID}",
  "major": 234
 }
]

Where:

If the user device is in proximity to a beacon and the device has Bluetooth turned on, the beacon pings the app (ping rate and success is affected by the beacon’s broadcast range and power settings).

Mobile apps can report beacon sightings to the platform using a POST to the /rest/beacon/detect endpoint:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
curl -i -X POST \
 https://api.{region}.te2.io/rest/beacon/detect \
    -H 'Authorization: Bearer {token}' \
    -H 'Content-Type: application/json' \
    -d '{
            "appUserId": "{appUserId}",
            "appId": "{appId}",
            "timestamp": 1561043804000,
            "beacons": [
            {
                "proximityUUID": "{UUID}",
                "major": 123,
                "minor": 1
            } ]
        }'