---
schema_version: "1"
id: 2aa453b875313707578683e09ac6082a6f5f3fcf033f2af3d923138fbe92e0a8
title: Location Tracking (Version 2.x)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-engagement-mobile-sdk/guides/c360a-api-engagement-mobile-sdk-location-tracking-v2.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-engagement-mobile-sdk/guide/c360a-api-engagement-mobile-sdk-location-tracking-v2.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 64f6bf65ccabb0f20394367e56923058c32e158d1a040cc7c77fde00ce9a8e58
products:
  - Data 360 Engagement Mobile SDK
  - Data 360 Developer Documentation
---
# Location Tracking (Version 2.x)

The Data 360 Module for the Engagement Mobile SDK supports location tracking for all events. Enable this functionality using the `setLocation` method on the Data 360 Module to set `coordinates` and `expiresIn`.

```
// Prepare the coordinates using the CdpCoordinates wrapper
let coordinates = CdpCoordinates(latitude: 54.187738, longitude: 15.554440)

// Set the location coordinates and expiration time in seconds
CdpModule.shared.setLocation(coordinates: coordinates, expiresIn: 60)
```

```
CdpSdk.requestSdk { sdk ->
    // Prepare the coordinates using the Coordinates wrapper
    val coordinates = Coordinates(latitude = 54.187738, longitude = 15.554440)

    // Set the location coordinates and expiration time in seconds
    sdk.setLocation(coordinates = coordinates, expiresIn = 60)
}
```

When the SDK has non-expired location coordinates, the location attributes are automatically appended to event attributes as key-value pairs with the key names `latitude` and `longitude`.

When the expiration interval is exceeded, the SDK location coordinates are cleared and no longer attached to events. To prevent location from being attached to events before the coordinates expire, call `setLocation` and pass `nil` values as the coordinates.

**note:** You're responsible for handling location tracking permission from the customer, requesting location permission, fetching the location, and ensuring the desired accuracy range.
