---
title: "Android: Technical Documentation"
description: "Reference the Lytics Android SDK configuration options, identify and track methods, data privacy controls, and utility functions."
url: "https://www.contentstack.com/docs/developers/sdks/lytics/android/technical-documentation"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-15"
---

# Android: Technical Documentation

The following outlines the full definition of capabilities supported by the Lytics SDK for Android.

## Configuration

When initializing the Lytics SDK with Lytics.shared.start, a variety of top-level configuration options are available to ensure the SDK can be tailored to the needs of your particular application:

Parameter

Description

Type

Default Value

apiKey

Your Lytics account API token.

String

\--

defaultStream

The default stream name event data will be sent. _Note: This can be overridden globally or at the event level._

String

android\_sdk

primaryIdentityKey

The key that represents the strongest identifier for users. _Note: Used primarily to retrieve a full profile for personalization._

String

\_uid

anonymousIdentityKey

The key that should be used to create and store the anonymous identifier.

String

\_uid

trackApplicationLifecycleEvents

A value that indicates whether application lifecycle events should be tracked automatically.

Bool

false

trackScreenViews

A value that indicates whether screen views should be tracked automatically.

Bool

false

trackPushNotifications

A value that indicates whether push notifications should be tracked.

Bool

false

trackDeepLinks

A value that indicates whether deep links should be tracked.

Bool

false

uploadInterval

The max interval in seconds at which the event queue is flushed and uploaded to the Lytics API.

Double

10

maxQueueSize

The max event queue size that can be stored before all queued events are flushed and sent to the Lytics API. \_Note: To disable a max queue size, set the value to 0.

Int

10

maxRetryCount

The max number of times to try and resend an event on failure.

Int

3

sessionDuration

The number of seconds a session should persist. Sessions expire if the app has been either closed or in the background for the number of seconds defined here.

Double

1200

enableSandbox

A boolean value indicating if events should be sent in "sandbox" mode. When in "sandbox" mode, any emitted events will not be processed by Lytics, but all logs will be available as are with live events.

Bool

false

logLevel

Set the logging level of the SDK.

LogLevel (.error, .debug, .info)

.error

Each of the above configuration options can be added to the initial Lytics.shared.start instantiation of the Lytics SDK as outlined here:

```
Lytics.init(applicationContext, LyticsConfiguration(
  apiKey = "YOUR-VALID-LYTICS-API-TOKEN",
  logLevel = LogLevel.DEBUG,
  defaultStream = "my_custom_anroid_stream",
  maxQueueSize = 10  
))
```

## Identifying Users

Lytics.identify is used to emit strong identifiers and attributes associated with your app user. This method provides a means to store the primary identifiers on the device itself so that all future event tracking from that device automatically is appended with information necessary to maximize the effectiveness of your identity resolution strategy. For each Lytics.identify call, you have the option to only store that data to the device or emit it to a Lytics event stream for mapping to profiles. Emitting all event types to a Lytics event stream is always our recommendation.

Parameter

Description

Type

stream

An optional definition of the Lytics event stream to send this particular event to. If left undefined (recommended), it will use the global default stream as assigned in the top-level config.

String

name

An optional name for the event. This may aid in validation, resolution, and mapping based on particular event types, such as "login."

String

timestamp

An optional timestamp to associate with the submitted identified event. This will default to the time the event is recorded. It is left undefined.

Timestamp

identifiers

A required set of key/value pairs representing strong identifiers and their values. For instance, an email address, user id, or any other information can be resolved to a single user.

Map

attributes

An optional set of key/value pairs that represent user attributes that are not to be used for data merging. These generally are things such as first name, last name, address, status, etc.

Map

shouldSend

An optional boolean value to determine if the identify event should only be stored on the device or also emitted to a Lytics event stream (recommended).

Bool

Example identify call where we set pass a custom stream, set of identifiers, and attributes:

```
Lytics.identify(
  LyticsIdentityEvent(
    stream = "sample-custom-stream", // optional
    identifiers = mapOf(
      "email" : "kevin@homealone.com",
    ),
    attributes = mapOf(
      "first_name" : "Kevin",
      "last_name" : "McCalister"
    )  
  )
)
```

## Tracking Events

Lytics.trackemits activity data for a particular app user to a Lytics even stream. Each track call will automatically be appended with the strong identifiers stored on the device to ensure the highest potential resolution against Lytics user profiles. Lytics.track calls can include a variety of optional parameters and data associated with the interaction as defined below:

Parameter

Description

Type

stream

An optional definition of the Lytics event stream to send this particular event to. If left undefined (recommended), it will use the global default stream as assigned in the top-level config.

String

name

An optional name for the event. This may aid in validation, resolution, and mapping based on particular event types, such as "login."

String

timestamp

An optional timestamp to associate with the submitted identified event. This will default to the time the event is recorded. It is left undefined.

Timestamp

identifiers

An optional set of key/value pairs representing strong identifiers and their values. For instance, an email address, user id, or any other information can be resolved to a single user. By default, all known identifiers will be automatically associated with the event. The best practice would be first to make an identify call unless the data would only be associated with a single event.

Map

properties

An optional set of key/value pairs that represent event properties that are not to be used for data merging. These generally are things such as total cost, content consumed, item clicked, etc.

Map

Example track call where we track a purchase event and its associated properties:

```
Lytics.track(
  LyticsEvent(
    name = "purchase",
    properties: mapOf(
      "total" : 19.99,
      "item" : "Slingshot"
    )
  )
)
```

### Screen Tracking

Lytics.screen is an additional method for appending device information to the traditional track call. This is an extension of the above definition and results in including the following information with all events:

*   Operating System Version
*   Device Model Name

## Data Privacy Controls

Depending on your application's particular needs, various data privacy controls are available by default. Below you'll find the optional methods and examples of scenarios where some or all may be most applicable.

### Consent

Lytics.consent is a specific event type for collecting critical information related to consent, such as location, document, etc. As a best practice, a Lytics.consent event should always be leveraged alongside the Lytics.optIn() event to ensure proper documentation of consent:

Parameter

Description

Type

stream

An optional definition of the Lytics event stream to send this particular event to. If left undefined (recommended), it will use the global default stream as assigned in the top-level config.

String

name

An optional name for the event. This may aid in validation, resolution, and mapping based on particular event types, such as "login."

String

timestamp

An optional timestamp to associate with the submitted identified event. This will default to the time the event is recorded. It is left undefined.

Timestamp

identifiers

An optional set of key/value pairs representing strong identifiers and their values. For instance, an email address, user id, or any other information can be resolved to a single user. By default, all known identifiers will be automatically associated with the event. The best practice would be first to make an identify call unless the data would only be associated with a single event.

Map

identifiers

A required set of key/value pairs representing strong identifiers and their values. For instance, an email address, user id, or any other information can be resolved to a single user.

Map

consent

An required set of key/value pairs that represent specific consent event properties that are not to be used for data merging. These generally are things such as type of consent, document reference, location, etc.

Map

```
Lytics.consent(
  LyticsConsentEvent(
    name = "android consent",
    identifiers: mapOf(
      "userid": "my-fake-userid-1234"
    ),
    attributes: mapOf(
      "firstName": "Kevin",
      "lastName": "McCalister"
    ),
    consent = mapOf(
      "documents": [
        "terms_jan_2023",
        "sharing_policy_jan_2023"
      ],
      "location": "Chicago, IL",
      "consented": true
    )
  )
)
```

### Opt In

Lytics.optIn() sets the state of a user's activity tracking preference. By default, all users are opted in. This default setting is fully configurable at the top-level SDK configuration. In either case, an explicit call to Lytics.optIn() will result in activities being tracked and sent to a Lytics stream.

```
Lytics.optIn()
```

### Opt Out

Lytics.optOut() is the opposite of the above Lytics.optIn() method and will prevent activity data from being emitted to Lytics after it has been called until an additional.Lytics.optIn() call has been made.

```
Lytics.optOut()
```

### GAID (Identifier for Advertisers)

[GAID](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/package-summary) or advertisingIdentifier is an alphanumeric string that is unique to each device. Collection of this identifier requires explicit confirmation from the app user, which the Lytics SDK for Android can trigger. In addition, upon confirmation, the GAID will be treated as a strong identifier and included with all outbound events emitted to Lytics streams for improved resolution.

The Lytics SDK for Android offers two methods to collect GAID and handle the opt-out of GAID.

To present a required modal asking for tracking access and storage/inclusion of the device-specific GAID upon confirmation, call the following method:

```
Lytics.enableGAID()
```

To disable the storing and emitting of the user's device-specific GAID, call the following method:

```
Lytics.disableGAID()
```

To support collecting the Android Advertising ID, add the following to the application's gradle dependencies:

implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'

Additionally, declare a Google Play services normal permission in the manifest file as follows:

<uses-permission android:name="com.google.android.gms.permission.AD\_ID"/>

After confirming with the user and getting their consent, enable Advertiser ID collection via Lytics.enableGAID().

The user's Android Advertising ID will be sent with each event's identifiers.

Note, the user can disable or change the Advertising ID via the Android system privacy settings.

## Utility

Several utility-type methods are available for flushing queues, resetting stored data, and performing general maintenance or debugging.

### Event Queue Flushing

Occasionally, it may be desired to force a flush of the event queue. This is common after a series of events, before sign-out, etc. This method will bypass any queue caps or timers and result in all queued events being emitted:

```
Lytics.dispatch()
```

### Stored Property Flushing

Strong identifiers and attributes are stored locally on the device. In general, there are not likely to be many use cases where it is necessary to delete all stored data and reset the SDK. By doing so, the resolution will become much more complex, and all identifiers, even anonymous, will no longer be accessible. That said, in the case of a shared device where a user is logging in and out or in the more common case of a test device, the following method is available to delete all data stored by the Lytics SDK for Android:

```
Lytics.reset()
```

### Access Stored Identifiers & Attributes

Be it for testing or presenting a profile to the end user, the complete stored device-level profile is available with the following method. Do note, this is only the stored data as a result of Lytics.shared.identify calls and does not represent the complete user profile from the Lytics system and cross-channel sources.

```
let userModel = await Lytics.shared.user
```