adjust-icon

Set up direct deep linking

When a user with your app installed clicks an Adjust link, direct deep linking ensures they’re taken directly to specific content within the app.

How it works

  1. User clicks an Adjust link.
  2. The OS opens your app and passes the deep link to native code (iOS or Android).
  3. The app_links library forwards the link to your Flutter code.
  4. Your code passes the link to the Adjust SDK for attribution. The SDK also resolves short branded links.
  5. Your code navigates the user based on the resolved link.

Adjust SDK methods

Use the Adjust.processDeeplink method, which does the following:

  • Records attribution from deep link clicks
  • Resolves short branded links to their long branded link equivalent
  • Passes through all other links as is
Method signature
static Future<String?> processDeeplink(String deeplink)

App will open URL (legacy)

The Adjust.appWillOpenUrl method records attribution from deep link clicks but doesn’t resolve short branded links.

Method signature
static void appWillOpenUrl(String url)

The processDeeplink method supersedes this legacy method.

Implementation

Use the app_links library to receive deep links and pass them to the Adjust SDK.

pubspec.yaml
dependencies:
app_links: ^6.0.0 # check pub.dev for latest version
final _appLinks = AppLinks();
Future<void> _initDeepLinks() async {
// Handle link when app is started from a deep link
final initialLink = await _appLinks.getInitialLink();
if (initialLink != null) {
_handleDeepLink(initialLink);
}
// Handle links when app is already running
_appLinks.uriLinkStream.listen(_handleDeepLink);
}
Future<void> _handleDeepLink(Uri incomingLink) async {
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
final resolvedLink = await Adjust.processDeeplink(incomingLink.toString());
// Handle failure if resolvedLink is null
if (resolvedLink == null) return;
/*
* TODO: Handle the deep link and navigate to the appropriate screen.
*
* Possible resolvedLink formats:
*
* 1. https://brandname.go.link/?adj_t=def456&
* adj_link=https%3A%2F%2Fexample.com%2Fsummer-clothes%3Fpromo%3Dbeach
* -> extract and decode the deep link from adj_link
*
* 2. https://brandname.go.link/summer-clothes?promo=beach&adj_t=def456
* -> extract path from the URL
*
* 3. example://summer-clothes?promo=beach&adj_t=def456
* -> extract path from the URL
*
* Note (Android only): If your Android app scheme path differs from iOS,
* you may receive:
* https://brandname.go.link/?adj_t=def456&
* adj_deep_link=example%3A%2F%2Fandroid-specific-path%3Fparam%3Dvalue
* -> extract and decode the deep link from adj_deep_link
*/
}

If your main activity is singleTop, standard, or doesn’t specify a launch mode, you need to create a dedicated deep link activity to ensure deep links open correctly when the app is already running.

This is required because without proper configuration, deep links might launch the app in a new task or within another app’s task (such as a browser), resulting in two instances of the app running simultaneously.

Native Android setup

  1. Configure the manifest using the Dedicated Deep Link Activity Approach
  2. Create a DedicatedDeepLinkActivity that forwards deep links to your main FlutterActivity
  1. User clicks an Adjust link.
  2. The OS opens your DedicatedDeepLinkActivity with the deep link Intent.
  3. DedicatedDeepLinkActivity forwards the Intent to your main FlutterActivity using flags that bring the existing instance to the front.
  4. FlutterActivity passes the deep link URI to the FlutterEngine.
  5. The FlutterEngine delivers the URI to your Dart code, where app_links receives it.

This flow is the same regardless of which Flutter deep linking library you use. No additional Flutter code is required to integrate with the Adjust SDK beyond what’s shown above.