Extending Functionality in Vuforia Studio with Code > Tracking Status API
  
Tracking Status API
You can use a JavaScript event called trackingstatuschanged to obtain information about changes to the tracking status of a target. The trackingstatuschanged event has a JSON payload that contains a key-value pair, with trackingStatus as the key and a status string value:
{"trackingStatus":"<tracking_status>"}
In the string above, the <tracking_status> variable can be any of the following statuses:
Status
Description
normal
The target is being tracked and indicates normal operation.
extended
The target is being tracked indirectly. It is either out of view, occluded, too far, or too close to be tracked directly.
limited
The target is being tracked but with very low accuracy.
limited_excessive_motion
Tracking is limited because the device is being moved too quickly.
* 
This status is only reported for Model Targets.
limited_insufficient_light
Tracking is limited because of poor lighting conditions.
* 
This status is only reported for Model Targets.
The event handler implemented in JavaScript has the following signature:
function(event, target, tmlNodeName, args)
The following is a table that lists and describes the available parameters:
Parameter
Description
event
The event object. This contains the trackingstatuschanged string for the name property.
target
Name or ID of the target.
* 
This will be an empty string for Spatial Targets.
tmlNodeName
Type of the object. The value will be twx-dt-target for this event.
args
String that includes the JSON event data.
Example
The following is an example implementation of the JavaScript event handler:
$scope.$on("trackingstatuschanged", function (event, target, tmlNodeName, args) {
trackingStatus = JSON.parse(args).trackingStatus;
console.log("Tracking Status Changed Script: event: " + event.name + ", target: " + target + ", tmlNodeName: " + tmlNodeName + ", args:" + args + ", trackingStatus: " + trackingStatus);
});
The following is an example of the log output:
Tracking Status Changed Script: event: trackingstatuschanged, target: 740de1d2-6202-45ab-94db-1056ecf2244b, tmlNodeName: twx-dt-target, args:{"trackingStatus":"extended"}, trackingStatus: extended