Dynamic Link
Dynamic links allow you to direct users to specific in-app content, track campaign performance, and handle platform-specific redirects (e.g., Play Store, iOS, desktop). With the AppTrove Andriod SDK, you can create dynamic links programmatically, embedding attribution and deep link parameters to enhance user acquisition and engagement.
Overview
Dynamic links provide a flexible way to route users based on their platform and context:
- Purpose: Generate links for campaigns, deep linking to specific app content (e.g., NewMainActivity).
- Use Case: Create a link like
https://vistmarket.shop/78R2J2
that directs users to a product page with parameters (productid=jeans
) and tracks campaign data (campaign=my_campaign
).
Key Features:
- Deep link to in-app destinations
- Attribution parameters for tracking
- Platform-specific redirects (Android, iOS, desktop)
- Social media previews for sharing
Example Link:
- Generated:
https://vistmarket.shop/78R2J2?param1=value1&campaign=my_campaign
- Redirects to:
https://apptrove.com?utm_redirect=sdk_link
or Play Store if app not installed
Configure Apptrove Panel
- Log in to the Apptrove Panel
- Go to Unilink Management > Create Template
- Setup Template
- Save and note the template ID (Required for Dynamic Link)
Implementation
- Java
- Kotlin
package com.example.myapp
import android.content.Context;
import android.net.Uri;
import android.util.Log;
import com.trackier.sdk.DynamicLink;
import com.trackier.sdk.TrackierSDK;
import java.util.HashMap;
import java.util.Map;
public class DynamicLinkHelper {
private void createDynamicLink(Context context) {
// Build the dynamic link parameters
Map<String, String> sdkParams = new HashMap<>();
sdkParams.put("param1", "value1");
sdkParams.put("param2", "value2");
DynamicLink dynamicLink = new DynamicLink.Builder()
.setTemplateId("78R2J2") // Set the template ID for the link ( Get this id from Apptrove Pannel)
.setLink(Uri.parse("https://apptrove.com?utm_redirect=sdk_link")) // The base link
.setDomainUriPrefix("vistmarket.shop") // Domain prefix for the link
.setDeepLinkValue("NewMainActivity") // Deep link destination within the app
// Additional SDK parameters
.setSDKParameters(sdkParams)
// Attribution parameters for tracking
.setAttributionParameters(
"my_channel",
"my_campaign",
"at_invite",
"param1_value",
"param2_value",
"param3_value",
"param4_value",
"param5_value"
)
// Android-specific parameters
.setAndroidParameters(
new DynamicLink.AndroidParameters.Builder()
.setRedirectLink("https://play.google.com?id=com.trackier.vistmarket")
.build()
)
// iOS-specific parameters
.setIosParameters(
new DynamicLink.IosParameters.Builder()
.setRedirectLink("https://www.example.com/ios")
.build()
)
// Desktop-specific parameters
.setDesktopParameters(
new DynamicLink.DesktopParameters.Builder()
.setRedirectLink("https://www.example.com/desktop")
.build()
)
// Social media preview settings
.setSocialMetaTagParameters(
new DynamicLink.SocialMetaTagParameters.Builder()
.setTitle("New Offer: Buy 1 Get 2 Free")
.setDescription("New deal is live now.")
.setImageLink("https://bluetooth_speaker.jpg")
.build()
)
.build();
// Call the SDK to create the dynamic link
TrackierSDK.createDynamicLink(
dynamicLink,
dynamicLinkUrl -> {
// Log success messages
// If performing any additional tasks, use Coroutine to avoid ANR issues
Log.d("DynamicLinkSuccess", dynamicLink.toString());
},
errorMessage -> {
// Log error messages
// If performing any additional tasks, use Coroutine to avoid ANR issues
Log.d("DynamicLinkError", errorMessage);
}
);
}
}
package com.example.kt
private fun createDynamicLink(context: Context) {
// Build the dynamic link parameters
val dynamicLink = DynamicLink.Builder()
.setTemplateId("78R2J2") // Set the template ID for the link ( Get this id from Apptrove Pannel)
.setLink(Uri.parse("https://apptrove.com?utm_redirect=sdk_link")) // The base link
.setDomainUriPrefix("vistmarket.shop") // Domain prefix for the link
.setDeepLinkValue("NewMainActivity") // Deep link destination within the app
// Additional SDK parameters
.setSDKParameters(mapOf("param1" to "value1", "param2" to "value2"))
// Attribution parameters for tracking user actions or events.
// Use `set` methods to define them, and you can verify the values later in the approval panel.
.setAttributionParameters(
channel = "my_channel",
campaign = "my_campaign",
mediaSource = "at_invite",
p1 = "param1_value",
p2 = "param2_value",
p3 = "param3_value",
p4 = "param4_value",
p5 = "param5_value"
)
// Android-specific parameters
.setAndroidParameters(
AndroidParameters.Builder()
.setRedirectLink("https://play.google.com?id=com.trackier.vistmarket")
.build()
)
// iOS-specific parameters
.setIosParameters(
IosParameters.Builder()
.setRedirectLink("https://www.example.com/ios")
.build()
)
// Desktop-specific parameters
.setDesktopParameters(
DesktopParameters.Builder()
.setRedirectLink("https://www.example.com/desktop")
.build()
)
// Social media preview settings
.setSocialMetaTagParameters(
SocialMetaTagParameters.Builder()
.setTitle("New Offer: Buy 1 Get 2 Free")
.setDescription("New deal is live now.")
.setImageLink("https://bluetooth_speaker.jpg")
.build()
)
.build()
// Call the SDK to create the dynamic link
TrackierSDK.createDynamicLink(dynamicLink,
onSuccess = { dynamicLinkUrl ->
// If performing any additional tasks, use Coroutine to avoid ANR issues
// Log success messages
Log.d("DynamicLinkSuccess", dynamicLink.toString())
},
onFailure = { errorMessage ->
// Log error messages
// If performing any additional tasks, use Coroutine to avoid ANR issues
Log.d("DynamicLinkError", errorMessage)
}
)
}
Configuration Parameters
Basic Parameters
Parameter | Type | Description | Required |
---|---|---|---|
templateId | string | Unilink template ID from the Trackier panel | Yes |
link | string | Base/fallback URL used in browsers and previews | Yes |
domainUriPrefix | string | Your verified/branded dynamic link domain | Yes |
deepLinkValue | string | App route/value to navigate after resolving | No |
Platform Parameters
Android Parameters (fallback when app not installed)
new DynamicLink.AndroidParameters.Builder()
.setRedirectLink("https://play.google.com/store/apps/details?id=com.example.app")
.build();
iOS Parameters (if link opened on iOS)
new DynamicLink.IosParameters.Builder()
.setRedirectLink("https://apps.apple.com/app/id123456789")
.build();
Desktop Parameters (browser fallback)
new DynamicLink.DesktopParameters.Builder()
.setRedirectLink("https://yourdomain.com/desktop")
.build();
Social Media Parameters (Open Graph)
new DynamicLink.SocialMetaTagParameters.Builder()
.setTitle("Your App Title")
.setDescription("Your app description for social sharing")
.setImageLink("https://example.com/share-image.jpg")
.build();
SDK Parameters (Custom Payload)
Map<String, String> sdkParams = new HashMap<>();
sdkParams.put("product_id", "123"); // Use IDs/refs; avoid PII
sdkParams.put("quantity", "2");
Attribution Parameters (Campaign Tracking)
.setAttributionParameters(
"social", // channel
"summer_sale", // campaign
"facebook", // mediaSource
"custom_param1", // p1
"custom_param2", // p2
"custom_param3", // p3
"custom_param4", // p4
"custom_param5" // p5
);