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.
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:
- Individual ad loader settings (higher priority)
- Global settings (lower priority)
Additionally, both setting methods create a ClickHandler implementation as shown in the example below, and detailed explanations follow.
- Kotlin
- Java
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
}
}
ClickHandler clickHandler = new ClickHandler() {
@Override
public boolean handleClick(@NonNull Context context, @NonNull String... clickThroughs) {
// Return true if click handling is successful
// Return false if click handling fails
}
};
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.
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.
- Kotlin
- Java
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()
)
GfpSdk.setSdkProperties(
GfpSdk.getSdkProperties().buildUpon()
.clickHandler(new ClickHandler() {
@Override
public boolean handleClick(@NonNull Context context, @NonNull String... clickThroughs) {
for (String clickThrough : clickThroughs) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(clickThrough));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return true;
} catch (Exception ignore) {
// 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
- Kotlin
- Java
val bannerAdView = GfpBannerAdView(this, adParam)
...
bannerAdView.setClickHandler(object: ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
...
}
})
GfpBannerAdView bannerAdView = new GfpBannerAdView(this, adParam);
...
bannerAdView.setClickHandler(new ClickHandler() {
@Override
public boolean handleClick(@NonNull Context context, @NonNull String... clickThroughs) {
...
}
});
When using GfpAdLoader
- Kotlin
- Java
val adLoader = GfpAdLoader.Builder(this, adParam)
.withClickHandler(object : ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
...
}
})
.build()
GfpAdLoader adLoader = new GfpAdLoader.Builder(this, adParam)
.withClickHandler(new ClickHandler() {
@Override
public boolean handleClick(@NonNull Context context, @NonNull String... clickThroughs) {
...
}
})
.build();
When using GfpRewardedAdManager
- Kotlin
- Java
val rewardedAdManager = GfpRewardedAdManager(this, adParam)
...
rewardedAdManager.setClickHandler(object : ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
...
}
})
GfpRewardedAdManager rewardedAdManager = new GfpRewardedAdManager(this, adParam);
...
rewardedAdManager.setClickHandler(new ClickHandler() {
@Override
public boolean handleClick(@NonNull Context context, @NonNull String... clickThroughs) {
...
}
});
When using GfpInterstitialAdManager
- Kotlin
- Java
val interstitialAdManager = GfpInterstitialAdManager(this, adParam)
...
interstitialAdManager.setClickHandler(object : ClickHandler {
override fun handleClick(context: Context, vararg clickThroughs: String): Boolean {
...
}
})
GfpInterstitialAdManager interstitialAdManager = new GfpInterstitialAdManager(this, adParam);
...
interstitialAdManager.setClickHandler(new ClickHandler() {
@Override
public boolean handleClick(@NonNull Context context, @NonNull String... clickThroughs) {
...
}
});
When using GfpVideoAdScheduleManager
- Kotlin
- Java
val videoAdScheduleManager = GfpVideoAdScheduleManager(...)
...
videoAdScheduleManager.setGfpVideoProperties(
GfpVideoProperties(0L, object: ClickHandler {
override fun handleClick(context: Context, vararg strings: String): Boolean {
...
}
})
)
GfpVideoAdScheduleManager videoAdScheduleManager = new GfpVideoAdScheduleManager(...);
...
videoAdScheduleManager.setGfpVideoProperties(
new GfpVideoProperties(0L, new ClickHandler() {
@Override
public boolean handleClick(@NonNull Context context, @NonNull String... strings) {
...
}
})
);
When using Prism player
- Kotlin
- Java
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
}
)
GladAdParams gladAdParams = new GladAdParams(
adParamOf(unitId, vid),
new VideoAdScheduleParam.Builder(unitId)
.setDuration(contentDurationMs / 1000L)
.setAdSchedulePolicy(pre, mid, post)
.setAdNoticeDurationSec(noticeDurationMs / 1000L)
.build(),
(context, clickThroughs) -> {
...
return true;
}
);