Skip to main content

Override Click Handling

This guide explains how to change the landing page that opens when an ad is clicked to an in-app internal browser or custom tab according to the integrated app's settings.

info

Click handling override is only supported for S2S (Server-to-Server) ads and is not supported for C2S (Client-to-Server) ads such as DFP, FAN, and AppLovin.

Click handling override can be configured in two ways: a global setting method that can be defined with SdkPropertiesBuilder.clickHandler() and a setting method for individual ad loaders. If both global settings and individual ad loader settings are configured, the priority is as follows:

  1. Individual ad loader settings (higher priority)
  2. Global settings (lower priority)

Additionally, both setting methods create a ClickHandler implementation as shown in the example below, and detailed explanations follow.

val clickHandler = object : ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
// Return true if click handling is successful
// Return false if click handling fails
}
}
danger

When implementing ClickHandler, you must return true only when click handling is successful in the handleClick() method. Accurate return values must be passed for proper billing to occur, so please make sure to check this.

info

The clickThroughs value passed as the second parameter of handleClick() can contain up to 2 values. Process the landing sequentially and return true only if either of the two landing processes is successful, and return false in all other cases.

Global Settings

This is a method of setting a ClickHandler implementation in the SdkPropertiesBuilder.clickHandler() method as shown in the example below.

GfpSdk.setSdkProperties(
GfpSdk.getSdkProperties().buildUpon()
.clickHandler(object : ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
for (clickThrough in clickThroughs) {
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(clickThrough))
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
return true
} catch (ignore: Exception) {
// do nothing
}
}
return false
}
})
.build()
)

Individual Ad Loader Settings

When separate click handling override is needed for specific ads, you can override separate click handling for each ad loader you use.

When using GfpBannerAdView

val bannerAdView = GfpBannerAdView(this, adParam)
...
bannerAdView.setClickHandler(object: ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
...
}
})

When using GfpAdLoader

val adLoader = GfpAdLoader.Builder(this, adParam)
.withClickHandler(object : ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
...
}
})
.build()

When using GfpRewardedAdManager

val rewardedAdManager = GfpRewardedAdManager(this, adParam)
...
rewardedAdManager.setClickHandler(object : ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
...
}
})

When using GfpInterstitialAdManager

val interstitialAdManager = GfpInterstitialAdManager(this, adParam)
...
interstitialAdManager.setClickHandler(object : ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
...
}
})

When using GfpVideoAdScheduleManager

val videoAdScheduleManager = GfpVideoAdScheduleManager(...)
...
videoAdScheduleManager.setGfpVideoProperties(
GfpVideoProperties(0L, object: ClickHandler {
override fun handleClick(context: Context, vararg strings: String): Boolean {
...
}
})
)

When using Prism player

val gladAdParams = GladAdParams(
param = adParamOf(unitId, vid),
scheduleParam = VideoAdScheduleParam.Builder(unitId)
.setDuration(contentDurationMs / 1000L)
.setAdSchedulePolicy(pre, mid, post)
.setAdNoticeDurationSec(noticeDurationMs / 1000L)
.build(),
clickHandler = { context, clickThroughs ->
...
true
}
)