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

Attribution

Attribution in Metrix refers to associating your application’s install with its precise source (such as an advertising campaign, a specific app store, or an APK file). This feature helps you accurately measure the performance of your marketing campaigns and allocate your budget to the most effective channels.

This section will guide you through implementing Metrix’s attribution capabilities in your Unity application.


1. Differentiating Organic Installs by Store

If you distribute your application across various app stores (like Cafe Bazaar, Google Play, Aptoide, F-Droid, or your own website), Metrix allows you to identify the source of your organic installs (installs not resulting from a specific advertising campaign) by store name.

To do this, you’ll need to create separate builds for each store and configure the respective store name within each build.

1.1. Setup for Android Applications

Add the store name to your application’s AndroidManifest.xml file as follows:

<manifest> ... <application> ... <meta-data android:name="metrix_storeName" android:value="STORE_NAME" /> </application> </manifest>

1.2. Setup for iOS Applications

Call the Metrix.SetStore method early in your application’s execution (e.g., in the Awake or Start method of a MonoBehaviour):

Metrix.SetStore("your_store_name"); // Example: Metrix.SetStore("AppStore");

2. Android Uninstall Tracking

Metrix uses silent push notifications to track application uninstalls on Android.

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

Setup Steps:

  1. Enter Firebase Project Push Credentials in the Metrix Dashboard:
  • Log in to your Metrix dashboard and navigate to your application settings.
  • Select the Uninstall Config tab.
  • Enter your Firebase project settings into the relevant fields.
  • Save the values by clicking the save button.
  • Tip: To obtain your Service account Data file, go to your Firebase console, navigate to Project Settings, select the Service Accounts tab, and click the Generate new private key button.
  1. Enable Uninstall Tracking: After entering the settings in the Metrix dashboard, enable uninstall tracking by toggling the corresponding option.

3. Setting a Default Tracker

You can define a default tracker for installs that don’t originate from a specific ad click (e.g., installs from an APK file directly hosted on your website). This feature helps you monitor organic installs or installs coming from specific sources (other than click-based campaigns) separately.

🚫
Caution

Important Warning: Under no circumstances should you release your application with a default tracker on official app stores (like Google Play or Cafe Bazaar). Doing so will incorrectly attribute all your organic and non-organic installs in Metrix to that default tracker, corrupting your actual install source statistics.

3.1. Setup for Android Applications

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

<manifest> ... <application> ... <meta-data android:name="metrix_trackerToken" android:value="TOKEN" /> </application> </manifest>

3.2. Setup for iOS Applications

Call the Metrix.SetDefaultTracker method early in your application’s execution:

Metrix.SetDefaultTracker("your_tracker_token"); // Replace with the default tracker token from Metrix dashboard

4. Deep Linking

If you use trackers with Deep Linking enabled, you can retrieve information about the deep link URL and its content within your application. The device’s behavior depends on whether the app is already installed (standard scenario) or not (deferred scenario) when the deep link is clicked.

This scenario occurs when a user clicks a deep link, and your application is already installed on their device. In this case, the deep link information is directly passed to your application, redirecting the user to specific content.

For implementing the standard scenario in Unity, you can refer to Unity’s official documentation on enabling deep linking here.

4.2. Deferred Deep Linking Scenario

This scenario occurs when a user clicks a deep link, but your application is not installed on their device at the time of the click. In this case, the user is redirected to the app store (like Google Play) to install your application. After installation and the first launch of the app, the deep link information is passed to your application, guiding the user to the intended content.

Metrix has its own mechanism to support Deferred Deep Linking on Android (which is not natively supported by the platform). If you intend to control this scenario, you can use the following Callback:

// Define your callback function to handle the deeplink void DeferredDeeplinkListener(string deeplink) { // Your custom logic to handle the deeplink URL (e.g., navigate to a specific screen) Debug.Log("Deferred Deeplink received: " + deeplink); } // Subscribe to the deeplink response listener Metrix.SetOnDeeplinkResponseListener(DeferredDeeplinkListener); // Control whether Metrix should automatically launch the deeplink Metrix.SetShouldLaunchDeeplink(true); // Set to 'true' for automatic launching, 'false' if you want to handle it manually in the callback
  • Metrix.SetOnDeeplinkResponseListener(DeferredDeeplinkListener): This method sets your DeferredDeeplinkListener function as the Callback for receiving deferred deep link information. After Metrix retrieves the deep link information from its server, it passes the content (deep link URL) to this Callback.

  • Metrix.SetShouldLaunchDeeplink(bool shouldLaunch):

    • If this method is called with true, Metrix will automatically execute the standard deep link scenario (i.e., opening the deep link URL in a browser or associated app). In this case, the Callback merely provides you with the information.
    • If called with false, Metrix will only provide the deep link information in the Callback and will not perform any automatic actions. In this case, you must implement your desired action within the application based on the received information in the Callback.

Note: The Deferred Deep Linking scenario is only executable if the application is installed via the Google Play Store (for Android).


5. Retrieving Campaign Information

You can retrieve information about the advertising campaign through which the user installed your application using the following method. This information is defined via your tracker in the Metrix dashboard.

// Define your callback function to receive attribution data void MetrixAttributionChangedListener(MetrixAttribution metrixAttribution) { // Your logic to handle attribution data Debug.Log("Attribution Data: " + metrixAttribution.acquisitionCampaign); } // Subscribe to the attribution changed listener Metrix.SetOnAttributionChangedListener(MetrixAttributionChangedListener);

The MetrixAttribution model (the metrixAttribution object in the above Callback) provides the following information:

  • metrixAttribution.acquisitionAd: Ad Name
  • metrixAttribution.acquisitionAdSet: Ad Set Name
  • metrixAttribution.acquisitionCampaign: Campaign Name
  • metrixAttribution.acquisitionSource: Ad Network Name
  • metrixAttribution.acquisitionSubId: Sub-ID
  • metrixAttribution.attributionStatus: Specifies the user’s status within the campaign.

The AttributionStatus value includes one of the following:

  • ATTRIBUTED: User has been attributed to a specific campaign.
  • NOT_ATTRIBUTED_YET: Attribution has not yet occurred (e.g., data is still processing).
  • ATTRIBUTION_NOT_NEEDED: Attribution is not required (e.g., the user is organic or outside a campaign).
  • UNKNOWN: Unknown status.

6. Retrieving Metrix Device IDs

Metrix generates a unique identifier (Metrix Device ID) for every device that installs your application. You can retrieve this ID as soon as the device is identified by the Metrix service.

To access this ID, use the Metrix.SetUserIdListener method:

// Define your callback function to receive the Metrix Device ID void MetrixUserIdListener(string metrixUserId) { // Your logic to use the Metrix Device ID Debug.Log("Metrix Device ID: " + metrixUserId); } // Subscribe to the user ID listener Metrix.SetUserIdListener(MetrixUserIdListener);

Note: The Metrix Device ID is provided to you once the device has been identified and registered by the Metrix service.


7. Session Management

Every interaction a user has with an application occurs within a Session. The Metrix library collects and provides you with information regarding different user sessions in your application and their durations.

7.1. Session ID

The Metrix library generates a unique identifier for each session. To retrieve this ID, call the Metrix.SetSessionIdListener method:

// Define your callback function to receive the Session ID void MetrixSessionIdListener(string sessionId) { // Your logic to use the Session ID Debug.Log("Metrix Session ID: " + sessionId); } // Subscribe to the session ID listener Metrix.SetSessionIdListener(MetrixSessionIdListener);

7.2. Current Session Number

Using the Metrix.SetSessionNumberListener method, you can retrieve the user’s current session number throughout their usage of your application. This number starts from 1 and increments with each new session.

// Define your callback function to receive the Session Number void MetrixSessionNumberListener(string sessionNumber) { // Your logic to use the Session Number Debug.Log("Metrix Session Number: " + sessionNumber); } // Subscribe to the session number listener Metrix.SetSessionIdListener(MetrixSessionNumberListener);
Last updated on