Skip to main content

How does it work?

When a new install occurs, Linkrunner sends the touchpoint details (media source and campaign ID) to GA4.

Steps to setup

In the Integrations tab, under Analytics, click Configure under Google Analytics. Firebase App ID and a Measurement Protocol API secret will be required. These are different for iOS and Android.To retrieve the Firebase App ID and Measurement Protocol API secret:
  1. Open Admin (settings icon) from the bottom-left of the Google Analytics interface.\ GA4 Admin
  2. Under PropertyData collection and modificationData streams, click your app data stream (iOS or Android).\ GA4 Data streams
  3. In the App stream details panel, copy the Firebase App ID.\ GA4 App stream details
  4. Under Events, click Measurement Protocol API secrets.\ GA4 Measurement Protocol API secrets
  5. Create (or reuse) an API secret and copy its value.
The Firebase App ID and API secret will be different for your iOS and Android apps, so repeat these steps for each platform.
The app instance ID uniquely identifies a specific installation of a Firebase app. This value needs to be retrieved from the Firebase SDK. After collecting this ID, pass it to linkrunner.signup so that Linkrunner can associate GA4 app instance IDs with installs and campaigns.Use the following examples to pass the app instance ID:
import com.google.firebase.analytics.FirebaseAnalytics
import io.linkrunner.sdk.LinkRunner
import io.linkrunner.sdk.models.request.UserDataRequest
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

private fun onSignup() {
    CoroutineScope(Dispatchers.IO).launch {
        try {
            val firebaseAnalytics = FirebaseAnalytics.getInstance(context)
            val appInstanceId = firebaseAnalytics.appInstanceId.await() // suspend extension from Kotlin coroutines

            val userData = UserDataRequest(
                id = "123", // Your user ID
                // ...other user fields
                gaAppInstanceId = appInstanceId, // GA4 app instance ID
            )

            LinkRunner.getInstance().signup(
                userData = userData
            )
        } catch (e: Exception) {
            println("Error during signup with GA4 app instance ID: ${e.message}")
        }
    }
}
The GA4 session ID uniquely identifies a session of a Firebase app. Similar to the app instance ID, this value is retrieved from the Firebase SDK and should be passed to linkrunner.signup so that session-level engagement can be connected to installs and campaigns.Use the following examples to pass the session ID (for example, ga_session_id or gaSessionId, depending on the SDK’s naming convention):
import com.google.firebase.analytics.FirebaseAnalytics
import io.linkrunner.sdk.LinkRunner
import io.linkrunner.sdk.models.request.UserDataRequest
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

private fun onSignup() {
    CoroutineScope(Dispatchers.IO).launch {
        try {
            val firebaseAnalytics = FirebaseAnalytics.getInstance(context)
            val sessionId = /* Retrieve GA4 session ID from your tracking layer */

            val userData = UserDataRequest(
                id = "123", // Your user ID
                // ...other user fields
                gaSessionId = sessionId, // GA4 session ID
            )

            LinkRunner.getInstance().signup(
                userData = userData
            )
        } catch (e: Exception) {
            println("Error during signup with GA4 session ID: ${e.message}")
        }
    }
}
To validate that data is flowing correctly between Linkrunner and GA4:
  • Use BigQuery Export to explore the raw event data with all associated parameters.
  • Using GA4 Explorations.
  • The Traffic acquisition report helps you understand where your app visitors are coming from. You can find this under Reports > Lifecycle > Acquisition > Traffic acquisition. For more information on the Traffic acquisition report, see the Google documentation.
BigQuery data is visible as soon as the event is received by GA4, while it can take 24–48 hours for data to reflect in GA4 reports. Read more here.