Analytics Regions
Optional
Needed if your app measures how long users spend in product categories or aisles.
Available since IPSFramework v9.9.0
Overview
Analytics regions are Regions that describe the merchandising layout of a store: category regions (the floor area of a product category) and aisle regions. Together with location visits, they let your app measure how much time users spend in each category or aisle, how far they walk there, and how long they stand still.
The basic flow (after a successful Login) is:
- Get the analytics regions of the building with IPSContent.getAnalyticsRegions(), filtered by type (category or aisle).
- Create an IPSLocationVisit for each region you want to monitor and register them with IPSProximity.add(locationVisits:).
- Receive IPSLocationVisitStatistics each time the user leaves a monitored region.
Getting Analytics Regions
Use IPSContent.getAnalyticsRegions() with the building ID and an IPSAnalyticsRegionType: .category or .aisle. Pass nil (the default) to get regions of all types.
IPSContent.getAnalyticsRegions(
buildingId: buildingId,
analyticsRegionType: .category,
onSuccess: { regions in
// Category regions of the building
},
onError: { error in
}
)
The method returns an IPSCancellable that can be used to cancel the request.
Analytics Region Object
IPSAnalyticsRegion extends IPSRegion, so it has all the properties described in the Regions guide, plus a region type:
| Property | Description | Example |
|---|---|---|
analyticsRegionType |
The type of the region: .category, .aisle, or .undefined. |
.category |
placements |
The region's placements, usually a single one. Each placement has a shape: rectangular (bottom-left and top-right corners), circular (center and radius in meters), or polygonal (list of vertices). See Region Shape. | Rectangle from (10.0, 30.22) to (100.0, 140.84) |
name |
Category regions: the category description. | Dairy |
clientDepartmentId |
Category regions: the category ID. Aisle regions: the aisle number. |
1023 / 59 |
metadata |
JSON with additional fields. Aisle regions: categories holds the IDs of the categories inside the aisle. |
{"categories": ["1023", "1056"]} |
Tip
The category and aisle data is set up by Oriient from the store's planogram data during onboarding.
Tracking Location Visits
An IPSLocationVisit describes a location to monitor and a callback that is invoked when the user leaves it:
groupId: optional ID used to remove several visits at once;buildingIdandfloorOrder: where the location is;locationDefinition: the area to monitor, an IPSLocalProximityEventLocationDefinition. For an analytics region, use.fromIPSAnalyticsRegion(_:). It returnsnilfor unsupported shapes;onLocationVisited: called with the visit statistics once the user leaves the location.
func onCategoryRegionsLoaded(_ regions: [IPSAnalyticsRegion], buildingId: String, floorOrder: Int) {
let visits: [IPSLocationVisit] = regions.compactMap { region in
guard let location = IPSLocalProximityEventLocationDefinition.fromIPSAnalyticsRegion(region) else {
return nil
}
return IPSLocationVisit(
groupId: "Category visits", // used to remove all these visits at once
buildingId: buildingId,
floorOrder: floorOrder,
locationDefinition: location,
onLocationVisited: { statistics in
reportCategoryVisit(region.clientDepartmentId, statistics)
}
)
}
IPSProximity.add(locationVisits: visits)
}
Important
Visits are detected from the user's position, so they are only tracked during an active Positioning session.
Visit Statistics
IPSLocationVisitStatistics describes a completed visit:
| Field | Description | Example |
|---|---|---|
travelDistance |
Distance (meters) traveled while inside the location. | 123.4 |
timeSpent |
Total time (seconds) spent in the location. | 32.1 |
enterTimestamp |
Date the user entered the location. |
2026-08-03 12:25:44 |
exitTimestamp |
Date the user exited the location. |
2026-08-03 12:39:29 |
timeDwell |
Time (seconds) the user stood still within the location. Use it to tell a real dwell from a pass-through. | 25.3 |
Managing Visits
- IPSProximity.add(locationVisits:) adds visits to the ones already registered;
- IPSProximity.set(locationVisits:) replaces the whole list;
- IPSProximity.remove(locationVisits:) removes the given visits (by reference);
- IPSProximity.removeAllLocationVisits(with:) removes every visit with one of the given
groupIds; - IPSProximity.removeAllLocationVisits() removes all visits.
func onUserLeftStore() {
IPSProximity.removeAllLocationVisits(with: ["Category visits"])
}