Source: https://developers.woosmap.com/products/geofencing-sdk/android-sdk/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 user's Visits



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

### Set up for Visits monitoring

The first step in collecting Visits is to set `VisitReadyListener`, this should be done in your `mainActivity` on the
method `onCreate`. It is recommended to use the `visitsTracking` profile to monitor visits and identify ZOI. You can
also enable the `visitEnable` setting if you don't want to use a preset tracking profile.

```java
@Override
protected void onCreate(Bundle savedInstanceState) {

    // [...] //

    this.woosmap.setVisitReadyListener (new WoosVisitReadyListener ());

    this.woosmap.startTracking( Woosmap.ConfigurationProfile.visitsTracking );
}
``` 

### Woosmap Visit Ready Listener

Create a listener connected to the interface `Woosmap.VisitReadyListener` and set a callback to
retrieve Visits event. This callback is triggered when a visit is identified.

```java
public class WoosVisitReadyListener implements Woosmap.VisitReadyListener
{
    public void VisitReadyCallback(Visit visit)
    {
        // this method is called when a visit is collected
    }
}
```

## Zone of Interest (ZOI)

### Set up for ZOI monitoring

ZOIs are built from visits, grouped by proximity. The Geofencing SDK implements the Fast Incremental Gaussian Mixture Model of classification
Algorithm  [FIGMM](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0139931) to build and update the
ZOI according to visits recurrence over time.

You can recover the ZOIs generated by making a request to the database.

```java
ZOI[] ZOIList = WoosmapDb.getInstance(mContext, true).getZOIsDAO().getAllZois();
```

Each ZOI includes the following information:

| Field name | Type     | Description                                                                                                                                            |
|------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| `idVisits`   | ArrayList<String>   | The list of id visits included in this ZOI.                                                                                                            |
| `latMean`    | double   | The latitude of the center of the ZOI (useful if you need to qualify the place of the visit with a search request over POIs or assets)                 |
| `lngMean`    | double   | The longitude of the center of the ZOI (useful if you need to qualify the place of the visit with a search request over POIs or assets)                 |
| `startTime`  | long | The entry date for the first ZOI visit.                                                                                                                |
| `endTime`    | long | The exit date of the last ZOI visit                                                                                                                    |
| `duration`   | long    | The duration of all the accumulated visits of the ZOI                                                                                                  |
| `wktPolygon` | String   | This is the [Well-known text representation of geometry](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) of the ZOI polygon. |
