Eco Report Scripted

The report measures harsh driving, speeding, use of seat belt and idling and it produces an “eco” score for each vehicle.


  • device that supports “harsh driving” signals (acceleration, turning, breaking). For example ATrack, Teltonika and Webtech (links to configuration guides at the bottom of this page)
  • VarPack 2 (included in new installations / downloadable from Plugins)

Install report

  1. Download this .zip file and extract the xml-files somewhere.
  2. Import the event rule Eco Report.xml in VehicleTracker. See this article for help.
  3. Import the reports EC2001 Eco Report (detailed).xml and EC2002 Eco Report (summary).xml . Go to SiteAdmin > Import, choose “template”. Click on “Choose file”, choose your reports and click on Import.
  4. Follow the instructions to activate these reports

Configure your Device Mapper

Your “harsh driving” signals must be mapped to the correct GpsGate variables for the Eco report to work:

  1. Go to Admin > Device Mapper in VehicleTracker
  2. Click Edit for the harsh driving compatible device
  3. Map the ignition signal from your device to the GpsGate variable Ignition. This is required for correct “idle” time.
  4. Map the device’s harsh signals to the GpsGate variables Harsh acceleration, Harsh turning and Harsh breaking.
  5. Create a variable called “SeatBeltStatus” in GpsGate Server. Go to SiteAdmin > Devices > Variables.
  6. Map the device’s Seat belt signal to the GpsGate variable you just created. Note: it’s not required to map all harsh signals, but remember to set e.g. var sBeltWeight = 0; if the seatBealtStatus variable is lacking signal.
  7. Save your changes and close the Device Mapper window

In vehicle tracker go to Reports > Manage Reports and select the reports:

Optional: Configure Speed Limit

If you want, you can change the speed that the Eco Reports counts as “overspeeding”:

  1. In VehicleTracker, open the Admin > Event Rules window.
  2. Notice the new rule called Eco Report that you just imported. This rule includes a Script Expression in which a special part of it is used to count speeding events in the Eco reports.
  3. Click Edit and alter var speedLimit = 90; in the Script Expression under the 4. Expression section to correspond to your desired speed limit.
  4. Make sure the script still runs after your change by clicking the test button. You should get something like Expression evaluates to: False in the test output terminal.
  5. Save your changes and verify that no warnings are displayed.
  6. Information about Using Real Speed Limits further down.

Optional: Configure the report - Weight parameters

The reports show a single “score” for each vehicle based on the “harsh” events and idling time. To do this, a formula is used, based on the following parameters:

“Eco” Formula:
EventOccurrences (harsh breaking, acceleration, turning, over speeding, use of seat belt, + any wanted measurements)
Score = Weight * EventOccurrences / Distance   + IdleTime / (IdleTime+ TripTime)

The weights are defined as variables in the script. Look for the passage in the script that’s enclosed with //Replace below to get “Custom Fields” and //Replace above to get “Custom Fields” and adjust them if you need. For each “Harsh” parameter the default value is 30. Preview the report to determine if any of the the weights need to be altered.Note: You might want to use different weights for different for trucks, cars etc, in the same Application. For that, please have a look at Using Custom Fields further down.
See “Modify Script” below for more info, (step 2-5 and 8-11) .

Optional: Modify Script

  1. Choose an editor, e.g. Notepad++.
  2. In VehicleTracker, open the Admin > Event Rules window.
  3. Notice the new rule called Eco Report that you just imported. This rule includes a Script Expression including most of the calculations for the report.
  4. Click Edit in the Script Expression under the 4. Expression section
  5. Get familiar with the output of the script by pressing the test button and observe the result
  6. Copy the whole script and paste it into the editor.
  7. Open one of the files, (included in the .zip-file you just downloaded), called EcoAddFunctionality.txt
  8. Modify your script, see different alternatives below
  9. Make sure the script runs, accept and save the event rule.
  10. Make sure to reprocess the data for the report. For that go to SiteAdmin > Plugin and install Developer tools.Then, SiteAdmin > Reporting > Reprocess.
  11. Generate the report and see updated results.

This script example has a length of 7420 characters and the limit is right now set to 10 000 characters. Please contact if you have a need for a longer script.

Optional: Using Real Speed Limits

  1. Install the Plugins MapClient and SpeedingExpression
  2. Follow step 1-7 in the Modify Script section.
  3. Replace what’s in between Replace below - “Get Dynamic Speedlimits from OSM” and Replace above - “Get Dynamic Speedlimits from OSM”. There are two parts; a function and some variables. Both are needed.
  4. Follow step 9-11 in the “Modify Script” section.

Optional: Using Custom Fields

You might want to use different weights for different for trucks, cars etc, in the same Application:

  1. Follow step 1-7 in the “Modify Script” section.
  2. Replace what’s in between Replace below - “Get Custom Fields” and Replace above - “Get Custom Fields”.
  3. Create these custom_fields and use them in the script, e.g. ‘harshAccWeight’ in the picture below.
  4. Follow step 9-11 in the “Modify Script” section.
//Replacebelow toget "Custom Fields"
var harshAccWeight = parseFloat(session.user.getCustomFieldValue('harshAccWeight') || 0);
var harshBrakeWeight = parseFloat(session.user.getCustomFieldValue('harshBrakeWeight') || 0);
var harshTurnWeight = parseFloat(session.user.getCustomFieldValue('harshTurnWeight') || 0);
var oSpeedWeight = parseFloat(session.user.getCustomFieldValue('oSpeedWeight') || 0);
var sBeltWeight = parseFloat(session.user.getCustomFieldValue('sBeltWeight') || 0);
var tripIdleWeight = parseFloat(session.user.getCustomFieldValue('tripIdleWeight') || 0);
var excellent = parseFloat(session.user.getCustomFieldValue('excellent') || 0);
var good = parseFloat(session.user.getCustomFieldValue('good') || 0);
var fair = parseFloat(session.user.getCustomFieldValue('fair') || 0);
//Replaceabove toget "Custom Fields"

Optional: Report driver instead of vehicle

If you have a driver connected to your vehicle you can report that driver instead of the vehicle:

  1. In VehicleTracker, open the Admin > Event Rules window.
  2. Alter “Who this rule applies to” to a tag with your drivers instead of your vehicles
  3. Follow step 1-7 in the “Modify Script” section.
  4. Search for the lines of code below in the script and comment out driver.username in 3 different places so that the script looks like the code below.
  5. Follow step 9-11 in the “Modify Script” section.
//DriverOrVehicleOrVehicle: session.driver.username, // place 1
DriverOrVehicleOrVehicle: session.vehicle.username, //
//var newDriverOrVehicle = (state.DriverOrVehicle != session.driver.username);//place 2
var newDriverOrVehicle = (state.DriverOrVehicle != session.vehicle.username);
//state.DriverOrVehicle = session.driver.username; // place 3
state.DriverOrVehicle = session.vehicle.username;

Strategy for adjusting your report

One strategy to get useful weights and evaluation criteria is to record drivers you know drive well. Let the resulting score define “Excellent” driving. Record the same driver when driving badly for a day or two, and let that score define “Fair” or “Risky” driving.
If you prefer to exclude the idling time points in your score, just edit “Score” column according to this

//Total Score
//Score per day

instead of this

//Total Score
$math.round(($sum([EventArgument12])/$sum([EventArgument])) + $sum([EventArgument15])/($sum([EventArgument13])+$sum([EventArgument14])))
//Score per day
$math.round(([EventArgument12]/[EventArgument]) + [EventArgument15] / ([EventArgument13] + [EventArgument14]))

If you prefer to exclude seat belt points just modify the script according to this

eventScore = accPts + brakePts + turnPts + oSpeedPts;

instead of this

eventScore = accPts + brakePts + turnPts + oSpeedPts + sBeltPts;