Geolocation
There are two options to attach geolocation information to Snowplow events:
- Based on the user IP address in enrichments.
- Using on device geolocation inside the Web or mobile app.
Geolocation based on the IP addressโ
Geolocation information can be automatically extracted from the IP address of the HTTP request to the collector. This is done during enrichment using the IP Lookup Enrichment.
You can see the information added to events as atomic event properties in this table.
Geolocation context entity tracked in appsโ
Geolocation information can also be fetched in the app using our trackers and attached to events as a context entity. This is often more accurate than the IP-based geolocation but requires permission from the user.
Context entity: geolocation_context
Schema for client geolocation contexts
Schema URI:iglu:com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0
Web | Mobile | Tracked automatically |
---|---|---|
โ | โ | โ |
๐ Example
{
"latitude": 30.04335623,
"longitude": 67.59633102,
"latitude_longitude_accuracy": -24902753.22,
"altitude": -19459.88,
"altitude_accuracy": -29970651.08,
"bearing": 21055653.32,
"speed": -7127794.98
}
๐ Schema properties definition
- Table
- JSON schema
Property | Type | Description | Required? |
---|---|---|---|
latitude | "number" | โ | |
longitude | "number" | โ | |
latitudeLongitudeAccuracy | ["number","null"] | โ | |
altitude | ["number","null"] | โ | |
altitudeAccuracy | ["number","null"] | โ | |
bearing | ["number","null"] | โ | |
speed | ["number","null"] | โ | |
timestamp | ["integer","null"] | โ |
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for client geolocation contexts",
"self": {
"vendor": "com.snowplowanalytics.snowplow",
"name": "geolocation_context",
"format": "jsonschema",
"version": "1-1-0"
},
"type": "object",
"properties": {
"latitude": {
"type": "number",
"minimum": -90,
"maximum": 90
},
"longitude": {
"type": "number",
"minimum": -180,
"maximum": 180
},
"latitudeLongitudeAccuracy": {
"type": [
"number",
"null"
]
},
"altitude": {
"type": [
"number",
"null"
]
},
"altitudeAccuracy": {
"type": [
"number",
"null"
]
},
"bearing": {
"type": [
"number",
"null"
]
},
"speed": {
"type": [
"number",
"null"
]
},
"timestamp": {
"type": [
"integer",
"null"
]
}
},
"required": [
"latitude",
"longitude"
],
"additionalProperties": false
}
How to track?โ
- Using the JavaScript tracker.
- Using the
TrackerConfiguration
object on the Android tracker and the iOS tracker.