adjust-icon

Smart Banner SDK dynamic 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 dynamic 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 dynamic deep link in the Smart Banner SDK:

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

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:

You can add your dynamic 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 dynamic 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",
});

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

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

In this example, the second call to setContext overwrites the context from the first call. The resulting dynamic 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 dynamic 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

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 dynamic 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" });

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 dynamic 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" });