Configure deep links

A deep link is a link that directs users to specific events or pages in your app. They offer a seamless experience by ensuring that users are directly routed to what they have seen in the smart banner. The Smart Banner SDK supports plain string deep links and deep link templates containing placeholders. Placeholders are filled by the SDK using provided deep link context or GET parameters of the web page URL.

There are two ways to configure a deep link in the Smart Banner SDK:

Configure your deep link path and context setters

Use these functions to configure your deep links and set dynamic context.

Set your deep link path

You must configure deep link paths for your target mobile platform using the setAndroidDeepLinkPath and setIosDeepLinkPath setter functions. These functions accept a string value that can be either an absolute path or a template path.

To set your deep link paths, call the AdjustSmartBanner.setIosDeepLinkPath and AdjustSmartBanner.setAndroidDeepLinkPath functions with the relevant paths to events or screens for each platform.

AdjustSmartBanner.setIosDeepLinkPath(
   "products/jeans/?product=cool-jeans&promo=spring_10"
);

The deep link path may contain any number of parameters enclosed in curly braces.

AdjustSmartBanner.setIosDeepLinkPath(
   "products/{category}/?product={product_id}&promo={promo}"
);

The Smart Banner SDK replaces these parameters with values from the context provided:

Set deep link context

You can add your deep link context by calling the AdjustSmartBanner.setContext function with an object containing key-value pairs of context values.

AdjustSmartBanner.setContext({
   category: "jeans",
   product_id: "cool-jeans",
   promo: "spring_10",
});

The Smart Banner SDK replaces any placeholder that matches a context key with the corresponding context value.

In this example, the resulting deep link path for iOS is products/jeans/?product=cool-jeans&promo=spring_10.

AdjustSmartBanner.setIosDeepLinkPath(
   "products/{category}/?product={product_id}&promo={promo}"
);
AdjustSmartBanner.setContext({
   category: "jeans",
   product_id: "cool-jeans",
   promo: "spring_10",
});
Important:
If no matching key is found in the context value, the Smart Banner SDK will try to use the value from the GET parameters in the current URL. If no matching parameter is found, an empty string is used.

In this example, the resulting deep link path for Android is products/jeans/?product=&promo=.

AdjustSmartBanner.setAndroidDeepLinkPath(
   "products/{category}/?product={product_id}&promo={promo}"
);
AdjustSmartBanner.setContext({ category: "jeans" });
Important:
The setContext method overrides the last preserved context. You should combine all required parameters in a single context object rather than calling the method multiple times.

In this example, the second call to setContext overwrites the context from the first call. The resulting deep link path is products//?product_id=blue_jeans as a blank string is substituted for the non-matching {category} parameter.

AdjustSmartBanner.setIosDeepLinkPath("products/{category}/?product={product_id}");
AdjustSmartBanner.setContext({ category: "jeans" });
AdjustSmartBanner.setContext({ product_id: "blue_jeans" });

In this example, the context is set correctly and the resulting deep link path is products/shoes/?product=red-sneakers.

AdjustSmartBanner.setIosDeepLinkPath("products/{category}/?product={product_id}");
AdjustSmartBanner.setContext({
   category: "shoes",
   product_id: "red-sneakers",
});

Use GET parameters as context

Important:
If your web app is a SPA (Single Page Application), the SDK can't detect changes to the URL. To ensure you always read the current URL's values, call AdjustSmartBanner.show() when the route changes.

If any of the parameters in your deep link path are missing in the context, the SDK will attempt to use parameters in the current page URL.

In the following example:

  • The category parameter is filled out using the value provided in the setContext setter.
  • The current page URL is https://my-shop.com/spring-promo?product_id=cool-jeans&promo=spring_10.

The SDK reads the values for product_id and promo from the page URL. The resulting deep link path is products/jeans/?product=cool-jeans&promo=spring_10.

AdjustSmartBanner.setAndroidDeepLinkPath(
   "products/{category}/?product={product_id}&promo={promo}"
);
AdjustSmartBanner.setContext({ category: "jeans" });
Important:
The context value passed by the setContext setter or the init method always take priority over GET parameters in the URL.

In the following example:

  • The product_id parameter is set by the setContext setter.
  • The current page URL is https://my-shop.com/spring-promo?product_id=cool-jeans&promo=spring_10.

Since the product_id value is set by the setContext setter, the value in the URL parameters is overridden. The resulting deep link path is products/jeans/?product=floral-jeans&promo=spring_10.

AdjustSmartBanner.setAndroidDeepLinkPath(
   "products/jeans/?product={product_id}&promo={promo}"
);
AdjustSmartBanner.setContext({ product_id: "floral-jeans" });