Source: https://developers.woosmap.com/products/geofencing-sdk/cordova-plugin/guides/monitor-user-visits/

> For clean Markdown of any page, append `.md` to the page URL.

> For a complete documentation index, see https://developers.woosmap.com/llms.txt

# Monitor POIs with Geofence



Get the location and the time spent when a user is visiting places. These use cases are explained in the [Visit and ZOI documentation](/products/geofencing-sdk/visits-zoi/).

## Collect user's Visits

### Enable visits and ZOI monitoring

It is recommended to use the `visitsTracking` profile to monitor visits and identify ZOI.

```js
cordova.plugins.WoosmapGeofencing.startTracking('visitsTracking', onSuccess, onError);
```

### Remove visits

Call `deleteVisit` method to remove all Visits from the local db.

```js
cordova.plugins.WoosmapDb.deleteVisit(success, error);
```

### Get visits from the local database

Call `getVisits` method to get an array of Visits from the local db.

```js
const success = function (result) {
        showSuccessToast("Total Visits: " + result.length);
    };
cordova.plugins.WoosmapDb.getVisits(success, error);
```

### Watch visit to track visit's events

Call `watchVisits` method to track Visits. Method will invoke a callback with Visit object. Method will return a
watch id which can be used later to remove the callback.

```js
const visitCallback = function (visit) {
	console.log("Visit:" + visit);
};

const error = function (err) {
	console.log(err);
};

var visitWatchId = cordova.plugins.WoosmapGeofencing.watchVisits(visitCallback, error);
```

To remove watch:

```js
cordova.plugins.WoosmapGeofencing.clearVisitsWatch(visitWatchId, success, error);
```

## Zone of Interest (ZOI)

### Remove ZOI

Call `deleteZoi` method to remove all Visits from the local db.

```js
cordova.plugins.WoosmapDb.deleteZoi(success,error);
```

### Get ZOI from the local database

Call `getZois` method to get an array of Visits from the local db.

```js
const success = function (result) {
        showSuccessToast("Total ZOIs: " + result.length);
    };
cordova.plugins.WoosmapDb.getZois(success, error);
```
