---
schema_version: "1"
id: fbd2a06ef28e17adf240225aa8c39abf1e95056ef849d17ff6fd3f751f591430
title: Location Tracking (Version 3.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-v3.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-engagement-mobile-sdk/guide/c360a-api-engagement-mobile-sdk-location-tracking-v3.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7108e0905e559dd4e5da56e3b5aba79360ea9729b5e430983a86b14a33b554b0
products:
  - Data 360 Engagement Mobile SDK
  - Data 360 Developer Documentation
---
# Location Tracking (Version 3.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, clear the location:

```
// Clear location immediately
CdpModule.shared.setLocation(coordinates: nil, expiresIn: 0)
```

```
// Clear location immediately
CdpSdk.requestSdk { sdk ->
    sdk.setLocation(null, expiresIn = 0L)
}
```

**note:** Location is also automatically cleared when consent is set to `optOut` / `OPT_OUT`.

**note:** You're responsible for handling location tracking permission from the customer, requesting location permission, fetching the location, and ensuring the desired accuracy range.
