Geofences

Introduction

Geofences represent custom regions or locations monitored in your project. Depending on your use case, a geofence might represent a retail store, a neighborhood, a delivery, and so on.

Alternatively, if you don't have your own custom place data, NearX can tell you when a user visits a place, even if you haven't set up a geofence for that place. Learn more about Groups.

How it works

NearX generates a geofence entry event if a user enters a geofence, then a geofence exit event when the user leaves the geofence with sufficient confidence.

Sample Event Trigger

  •   {
            "app_name": "NearXApp",
            "fence_radii": [100],
            "fence_name": "SPAR SuperMarket Bangalore",
            "fence_canonical_name": "SPAR SuperMarket Bangalore:100:GEOFENCE",
            "fence_type": "N",
            "expiry": "2019-07-02T13:50:03.643Z",
            "groupIds": [1],
            "customer_id": "8939407232",
            "type": "GEOFENCE_ENTRY",
            "accuracy": "80%"
        }

Create geofences

You can create geofences via the dashboard or API integrations using your key.

Dashboard

To create a geofence via the dashboard, go to the places page and click the Create New button. Optionally search for an address or place, then enter a description.Choose circle to draw a circle geofence. Click Create to create the geofence.

Note: For maximum reliability, create geofences with a radius of 100 meters or bigger and add padding to compensate for location accuracy. While you can create geofences with a smaller size, events may not be generated, or may be generated only after the user stops for a few minutes. In general, these restrictions apply to all apps and SDKs using location services on iOS and Android, not just NearX.

create place


API

Register with us, to generate sample token. Using token, invoke our API as below,

  •   curl -i -X 'https://dev-api.getwalk.in/nearx/api/create-geofence/' \
              -H 'Content-Type: application/json' \
              -H 'token: <<SampleToken>>'
              -D '{
                "geofenceInput":{
                  "geofenceName":"CCD",
                  "location":{
                    "lat": 12.9131684
                    "lng": 77.6498837
                  }
                  "radii":100,
                  "address":"CCD in HSR",
                  "area": "HSR",
                  "city": "Bangalore",
                  "state":"KA",
                  "country":"India"
                }
              }'

    Geofences can be uniquely referenced by their ID, assigned by NearX when a geofence is created.

Dwell time detection

When Geofence Dwell time Detection is on, NearX will calculate the time difference between a user last geofence entry event and exit event. Dwell time will be included in the event data. Turn on Geofence Dwell time Detection globally on the Settings page, under Geofences.

Support

Have questions after reading the documentation? Contact us here