Counting Installs and Tracking User Sessions (For Attribution Service)
To enable user session tracking via the Metrix SDK, include the following configuration inside the config object — the third parameter of the init method:
{
sessionTracking: {
enabled: true; // default is false.
packageName: 'YOUR_APP_PACKAGE_NAME';
}
}Counting Installs in TWA Apps
Since identifiers required for attribution (such as Google Advertising ID) are not accessible in a web environment, and in TWA (Trusted Web Activity) the only communication link between the native Android app and the web app is the Launch URL,
to ensure accurate attribution and install counting, the Android app must retrieve the required identifier using Google’s libraries and append it as a query parameterto the web app’s launch URL.
Add the following dependency to your Android project to access the Google Advertising ID:
com.google.android.gms:play-services-ads-identifier:18.0.1You can find the official documentation for retrieving the Google Advertising ID from this link :
This ID must be added with the key
gps_adidto the query parameters of the web app launch URL, as in the following example:https://domain.example?gps_adid=DEVICE_ADVERTISING_ID
Sample TWA implementations that demonstrate how to retrieve the Google Advertising ID are available for both Java and Kotlin
Counting Installs in PWA Apps
In Progressive Web Apps (PWAs), since there’s no access to a unique device identifier,
the first user session is considered the app installation.
Therefore, to count installs in PWAs, no special setup is required — just ensure session tracking is enabled as described earlier.
Retrieving the Unique Identifier
For every device that installs your app, Metrix generates a unique identifier.
You can access this ID right after the device is recognized using the following method:
onMetrixUserIdReceived().then((metrixUserId: string) => {
// todo
});This identifier is useful when you need to send events Server-to-Server to Metrix via the API.