Skip to Content
AI Powered Docs! 🤖 These docs are translated with AI, so keep an eye out for minor quirks. We're always improving!

Attribution

With the initial implementation from the Getting Started section, your installs will be automatically attributed to the installation source (tracker).

To implement other attribution features, you can study this section.

Differentiating Organic Installs by Store

If you want to publish your application on different stores such as Cafe Bazaar, Google Play, etc., you can track which store (e.g., Cafe Bazaar, Google Play, Myket, website, etc.) the user installed the application from and identify the sources of your organic installs.

To do this, you need to create separate builds for your application for publication on different stores and configure the corresponding store name in each build.

Place the store name in your application’s AndroidManifest.xml file as follows:

<manifest> ... <application> ... <!-- Add the following lines and replace with the store name --> <meta-data android:name="metrix_storeName" android:value="YOUR_STORE_NAME" /> </application> </manifest>

Uninstall Tracking

Metrix uses silent push notifications to track when your application is uninstalled.

To use this feature, you must utilize Firebase Cloud Messaging (FCM).

Follow these steps:

  • Enter Push Credentials for the Firebase project in the Metrix panel

Go to your application settings in the Metrix panel and select the Uninstall Config tab.
Enter your Firebase project settings in the relevant fields and click the Save button to store the values.

To obtain the Service Account Data file, go to your Firebase console, navigate to Project Settings, select the Service Accounts tab, and click Generate New Private Key.

push configuration

  • Activating Uninstall Tracking

After entering the settings in the Metrix panel, enable uninstall tracking by turning on the corresponding toggle.

  • Sending Push Token in the Application

After implementing FCM in your application, when you receive the push notification token, send this token to Metrix by calling the following method:

MetrixAttribution.setPushToken("pushToken");

Setting a Default Tracker

You can assign a tracker to users whose installation does not result from a click. To do this, you need to place the identifier of the tracker you defined in the panel within the application.

This feature is useful when you intend to distribute your APK file directly and want to track the installation statistics from this distribution separately in Metrix.

Note: Under no circumstances should you publish your application on the store with a default tracker. Doing so will cause all your organic installations to be counted under that tracker in Metrix.

Place the tracker identifier in your application’s AndroidManifest.xml file as follows:

<manifest> ... <application> ... <!-- Add the following lines and replace with the identifier --> <meta-data android:name="metrix_trackerToken" android:value="TOKEN" /> </application> </manifest>

Deep Linking

If you use trackers with deep linking enabled, you can receive the deep link URL and its content. The device responds based on whether the application is installed (standard scenario) or not installed (deferred scenario). If your application is installed, the deep link information is sent to your application.

The Android platform does not automatically support the deferred scenario. In this case, Metrix has its own specific scenario to deliver deep link information to the application.

Standard Scenario

If your users have your application installed and you want a specific page of your application to open after clicking on a deep link, you must first choose a unique scheme name. Then, you need to assign it to the activity you intend to launch when the deep link is clicked. To do this, go to the AndroidManifest.xml file and add the intent-filter section to the desired activity, along with your chosen scheme name. As shown below:

<activity android:name=".MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="metrixExample" /> </intent-filter> </activity>

The deep link information is accessible in the activity where you defined it through an Intent object in the onCreate and newIntent methods.

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent(); Uri data = intent.getData(); }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Uri data = intent.getData(); }

Deferred Scenario

This scenario occurs when a user clicks on a deep link but does not have your application installed on their device at the time of clicking. In this case, after clicking, the user is redirected to Google Play to install your application. Upon installation, during the first launch, the deep link information is passed to the application.

If you wish to handle the deferred scenario, you can use the following callback:

Native
MetrixAttribution.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { // ... if (shouldMetrixSdkLaunchTheDeeplink(deeplink)) { return true; } else { return false; } } });
Webview
MetrixAttribution.setOnDeeplinkResponseListener(deeplink => { //TODO });

After Metrix retrieves the deep link information from its server, it passes the content to the above callback. If the return value of the launchReceivedDeeplink method is true, Metrix automatically executes the standard scenario. However, if the return value is false, Metrix only provides the information in this callback for you to perform your desired action based on it.

Note: The deferred scenario can only be executed if the application is installed via the Google Play Store or Cafe Bazaar.

Retrieving Campaign Information

Using the following method, you can retrieve the information of the advertising campaign you have set in your tracker within the panel.

Native
MetrixAttribution.setOnAttributionChangedListener(new OnAttributionChangeListener() { @Override public void onAttributionChanged(AttributionData attributionData) { //TODO } });
Webview
MetrixAttribution.setOnAttributionChangedListener(attributionData => { //TODO });

The AttributionData model provides you with the following information:

attributionData.getAcquisitionAd() // Ad name attributionData.getAcquisitionAdSet() // Ad group attributionData.getAcquisitionCampaign() // Advertising campaign attributionData.getAcquisitionSource() // Advertising network attributionData.getAcquisitionSubId() // Ad subgroup attributionData.getAttributionStatus() // Indicates the user's status in the campaign

The value of AttributionStatus includes one of the following:

  • ATTRIBUTED - Attributed
  • NOT_ATTRIBUTED_YET - Not yet attributed
  • ATTRIBUTION_NOT_NEEDED - Attribution not needed
  • UNKNOWN - Unknown status

Retrieving Metrix Device Identifiers

For each device that installs your application, Metrix generates a unique identifier that you can retrieve as soon as it is identified. You can access this identifier using the following method:

Native
MetrixAttribution.setUserIdListener(new UserIdListener() { @Override public void onUserIdReceived(String metrixUserId) { // your logic } });
Webview
MetrixAttribution.setUserIdListener(userId => { // your logic });

Note: The Metrix identifier will be available to you once the device has been identified by the Metrix service.

Session

Every interaction a user has with an application occurs within a session. The Metrix library collects information about the user’s various sessions in your application and their durations, making it available to you.

Session Identifier

The Metrix library generates a unique identifier for each session, which you can retrieve. To obtain this identifier, call the following method:

Native
MetrixAnalytics.setSessionIdListener(new SessionIdListener() { @Override public void onSessionIdChanged(String sessionId) { // your logic } });
Webview
MetrixAnalytics.setSessionIdListener(sessionId => { // your logic });

Current Session Number

Using the following method, you can track the user’s current session number throughout their entire usage of your application:

Native
MetrixAnalytics.setSessionNumberListener(new SessionNumberListener() { @Override public void onSessionNumberChanged(String sessionNumber) { // your logic } });
Webview
MetrixAnalytics.setSessionNumberListener(sessionNumber => { // your logic });