Configuring Location Tracking and Track Views For Your Organization

Location tracking is an organization-wide capability, providing the ability to record where users are and where they have been. Location tracking makes use of a feature service that stores tracked locations as point features in the scalable spatiotemporal big data store. The tracks are secure within the location tracking service: users only see their own tracks, with additional permissions required to view the tracks of others. The tracks can be used for situational awareness and for analysis to answer questions related to where users have been.

ArcGIS Tracker empowers location tracking, using two apps: the Track Viewer web app and the ArcGIS Tracker mobile app. The Track Viewer web app enables administrators to create track views, defining who is tracked and who can view those tracks. The Tracker mobile app is optimized for tracking locations in the field, running in background while minimizing the impact on device battery. The mobile app records tracks whether or not there is a data connection, and gives mobile users control of when they are and aren't tracked.

The ArcGIS API for Python makes it easy to manage location tracking capability in an automated, repeatable, and scalable way.

Configuring Location Tracking

An authenicated administrator is able to configure location tracking via the LocationTrackingManager.

import arcgis
dir(arcgis.apps.tracker)
['LocationTrackingError',
 'LocationTrackingManager',
 'MobileUserManager',
 'TrackView',
 'TrackViewerManager',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '_errors',
 '_location_tracking',
 '_track_view']
from arcgis.gis import GIS
from arcgis.apps.tracker import TrackView

gis = GIS(profile="your_enterprise_portal")
location_tracking = gis.admin.location_tracking

Location Tracking has three states enabled, paused, and disabled. It's easy to check the status of Location Tracking.

location_tracking.status
'disabled'

An administrator is able to enable location tracking via the LocationTrackingManager.

location_tracking.enable()
True

When location tracking is enabled, a new item gets created representing the Location Tracking Feature Service. Any mobile user can upload their tracks to this service. This item can be easily accessed using the LocationTrackingManager object.

location_tracking.item
location_tracking
Feature Layer Collection by apulver
Last Modified: May 02, 2019
0 comments, 0 views

The Location Tracking Feature Service has two layers. The first layer,tracks, stores the historical breadcrumbs of each user. The second layer, last_known_locations, stores the most recent location of each user that is using the Tracker mobile app. These layers can be easily accessed via the LocationTrackingManager.

location_tracking.tracks_layer
<FeatureLayer url:"https://pythonapi.playground.esri.com/server/rest/services/Hosted/location_tracking/FeatureServer/0">
location_tracking.last_known_locations_layer
<FeatureLayer url:"https://pythonapi.playground.esri.com/server/rest/services/Hosted/location_tracking/FeatureServer/1">

By default, the tracks layer has a retention period of 30 days which means tracks will only be stored for 30 days. An administrator is able to configure the retention period to suit their organization's needs. Let's see how to set the retention period to 6 months.

location_tracking.retention_period = 6
location_tracking.retention_period_units = "MONTHS"

Additionally, if an organization wants to keep their tracks forever, the retention period can be turned off.

location_tracking.retention_period_enabled = False

Creating and Configuring a Track View

A core concept of Location Tracking is that certain users in the organization are able to view the tracks of others. This is accomplished by creating a "Track View". A track view is a feature service view created from the Location Tracking Service. It contains a list of Mobile Users representing the users whose tracks will be displayed, and a list of Track Viewers who will have access to see those users tracks. A Track View can easily be created by an administrator.

track_view = location_tracking.create_track_view("Demo Track View")

The create_track_view() function returns a TrackView object. An adminstrator can easily add viewers to the TrackView:

track_view.viewers.add(['tracker_demo'])

Similarily an administrator can add mobile users to the Track View

track_view.mobile_users.add(['tracker_demo'])

It's easy to see who the track viewers and mobile users are in a TrackView

track_view.viewers.list()
['tracker_demo', 'apulver']
track_view.mobile_users.list()
['tracker_demo']

The TrackView provides access to both the tracks and last known locations layers so they can easily be used for analysis

track_view.tracks_layer
<FeatureLayer url:"https://pythonapi.playground.esri.com/server/rest/services/Hosted/98bebbeb4dcf4bbc942c24c2595fabc2_Track_View/FeatureServer/0">
track_view.last_known_locations_layer
<FeatureLayer url:"https://pythonapi.playground.esri.com/server/rest/services/Hosted/98bebbeb4dcf4bbc942c24c2595fabc2_Track_View/FeatureServer/1">

Track views can easily be searched for as follows:

items = gis.content.search("typekeywords:'Location Tracking View'")

A TrackView object can be created from an item as follows:

track_view2 = TrackView(items[0])
track_view2
<arcgis.apps.tracker._track_view.TrackView at 0x1190c6240>

Managing Tracker Licenses

In order to sign into the Tracker mobile app and upload tracks, users must be provisioned an ArcGIS Tracker License.

We can see how many licenses are available and how many are assigned

tracker_license = gis.admin.license.get('ArcGIS Tracker')
tracker_license.report
EntitlementTotalAssignedRemaining
0tracker50050

An ArcGIS Tracker License can be assigned as follows

tracker_license.assign(username='tracker_demo', entitlements=["tracker"])
True

Similarily a license could be revoked

tracker_license.revoke(username='tracker_demo', entitlements=["tracker"])
True

Managing the "view location tracks" privilege

In order for track viewers to see the tracks of other users in the organization (through a Track View), they must have a role that has the "view location tracks" privilege. The administrator role has this privilege by default. Non-administrators will need to be assigned a custom role that has this privilege. A custom role that can view tracks can be created as shown below.

track_viewer_role = gis.users.roles.create(
    name='Track Viewer',
    description="A user that can use the Track Viewer web app to see others tracks",
    privileges=[
        "portal:user:joinGroup",
        "portal:user:viewTracks",
    ]
)

The custom role can then be assigned to a user.

user = gis.users.get('tracker_demo')
user.update_role(track_viewer_role)
True

Conclusion

This guide explains how an administrator can enable the location tracking capability, and once enabled, how track views can be created and users be added to it. It also explains how an administrator can assign licenses for the Tracker field app to desired users and how custom roles with privileges to view tracks of other users be created.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.