Scripting with geofence group color and priority

Geofence groups can be assigned priorities and colors. Geofences display the color of the highest priority geofence they belong to. You can solve many customer requests by combining geofences, event rules, and click scripts. For more background on geofences and geofence priority, click here.


Example 1: There is a NO-ENTRY area where no vehicles should enter. 

Download the sample click script. (When importing the click script XML, it will import the appropriate event rule together.) 
Click here to learn how to export-import event rules. 


  1. First, we need to create a geofence on the access-limited area. You can use any kind of geofence to cover the area (depending on its shape). Here we are using a route geofence.  Screenshot_2021-01-29_at_10.15.40.png

  2. Create two geofence groups:
    A normal group with priority 100 and an alarm group with priority 200. 
  3. Now we can create an 'Inside Geofence' event rule. 
    Here we are using a script event rule to remember the current geofence and the previous geofence. 
  4. Create a new click script using "Notifier" as the trigger option for the new event rule (which we created in step 1). 

  5. In the click script, we will use the GEOFENCE_ID (which comes from the event rule) and check if there are any vehicles inside the geofence. If yes, then we will add the geofence to the Alarm Geofence group. Then the geofence will change to selected Alarm Geofence color. The admin can see the geofence color directly on the application map or in the Fleet app.

  6. When the vehicle leaves the geofence, the geofence will be removed from the alarm group and the color will back to normal. 

Example 2: For the cargo unloading area, I would like to check if the area is busy. Are the trucks are moving slowly or waiting in a long queue?

Using the script from Example 1, add more options to the script. You can use message.connect to load a vehicle's variables and calculate the speed, check the ignition status, etc. 

Example 3: I would like to see if all of my vehicles come back to the parking area at night. I want to see this directly on the map or in the Fleet app without checking them one by one.

We can get the click script to check the number of vehicles inside the geofence. If the number is the same as the predefined number, then we will put the geofence to "Full" group, otherwise, will show "Normal" status. 

Download the sample click script. 


By using the function "geofences.getUsers" in the click script, you can get all the vehicles inside the geofence and create the logic as your business rule.