Ad Parameters
AdParam
The AdParam class encapsulates various information required for ad requests, including the essential Ad Unit ID and other parameters for ad targeting.
You can create an instance using the AdParam.Builder, as shown in the examples below.
- Kotlin
- Java
val adParam = AdParam.Builder()
.setAdUnitId("AOS_TEST_BANNER") // Ad Unit ID
.setCurrentPageUrl("https://www.naver.com") // Description link for the current page
.setRefererPageUrl("https://www.naver.com") // Referer information
.addCustomParam("channelId", "41312") // Supports targeting settings and reporting via NAM Admin
.build()
AdParam adParam = new AdParam.Builder()
.setAdUnitId("AOS_TEST_BANNER") // Ad Unit ID
.setCurrentPageUrl("https://www.naver.com") // Description link for the current page
.setRefererPageUrl("https://www.naver.com") // Referer information
.addCustomParam("channelId", "41312") // Supports targeting settings and reporting via NAM Admin
.build();
Key Methods of AdParam.Builder
Method | Description |
---|---|
setAdUnitId() | Sets the Ad Unit ID. This is a required field when requesting ads. |
addCustomParam() | Adds a custom parameter for targeting. Keys and values should be confirmed and agreed upon with the NAM administrator. |
setCustomParam() | Sets custom parameters for targeting. Use this to add multiple custom parameters. |
setCurrentPageUrl() | Sets the current page URL for targeting. |
setRefererPageUrl() | Sets the referer page URL for targeting. |
setApsParam() | Sets APS parameters. Required for header bidding; refer to the Header Bidding guide for details. |
When setting custom parameters, use the | character to separate multiple values for a single key.
Global Settings for the SDK
In addition to configuring AdParam for each ad request, you can manage global settings using SdkProperties and user-related settings using UserProperties.
SdkProperties
The SdkProperties object manages global SDK settings such as ad request timeouts, audio mute settings, and ad provider options.
You can create an instance using the SdkPropertiesBuilder, as shown in the examples below.
- Kotlin
- Java
GfpSdk.setSdkProperties(GfpSdk.getSdkProperties().buildUpon()
.addProviderOptions(DfpProviderOptions.Builder().setTestMode(false).build())
.addProviderOptions(FanProviderOptions.Builder().setTestMode(false).build())
.addProviderOptions(NdaProviderOptions.Builder().setTheme(ResolvedTheme.SYSTEM).build())
.addProviderOptions(UnityProviderOptions.Builder().setTestMode(false).build())
.bannerAdRequestTimeout(60_000L)
.unifiedAdRequestTimeout(60_000L)
.videoAdRequestTimeout(60_000L)
.interstitialAdRequestTimeout(60_000L)
.rewardedAdRequestTimeout(60_000L)
.muteAudio(true)
.build())
GfpSdk.setSdkProperties(GfpSdk.getSdkProperties().buildUpon()
.addProviderOptions(new DfpProviderOptions.Builder().setTestMode(false).build())
.addProviderOptions(new FanProviderOptions.Builder().setTestMode(false).build())
.addProviderOptions(new NdaProviderOptions.Builder().setTheme(ResolvedTheme.SYSTEM).build())
.addProviderOptions(new UnityProviderOptions.Builder().setTestMode(false).build())
.bannerAdRequestTimeout(60_000L)
.unifiedAdRequestTimeout(60_000L)
.videoAdRequestTimeout(60_000L)
.interstitialAdRequestTimeout(60_000L)
.rewardedAdRequestTimeout(60_000L)
.muteAudio(true)
.build());
Key Methods of SdkPropertiesBuilder
Method | Description |
---|---|
bannerAdRequestTimeout() | Sets the request timeout (in milliseconds) for banner ads loaded via GfpBannerAdView. Default is 60,000 milliseconds. |
unifiedAdRequestTimeout() | Sets the request timeout (in milliseconds) for ads loaded via GfpAdLoader. Default is 60,000 milliseconds. |
rewardedAdRequestTimeout() | Sets the request timeout (in milliseconds) for rewarded ads loaded via GfpRewardedAdManager. Default is 60,000 milliseconds. |
interstitialAdRequestTimeout() | Sets the request timeout (in milliseconds) for interstitial ads loaded via GfpInterstitialAdManager. Default is 60,000 milliseconds. |
muteAudio() | Configures whether non-instream video ads should be muted. Default is true. |
UserProperties
The UserProperties object manages user-related information, including gender, year of birth, country, language, and user ID. These properties are used for ad targeting.
You can create an instance using the UserPropertiesBuilder, as shown in the examples below.
- Kotlin
- Java
GfpSdk.getUserProperties().clearCustomParameter()
GfpSdk.setUserProperties(GfpSdk.getUserProperties().buildUpon()
.yob(1987)
.country("KR")
.language("KO")
.gender(GenderType.MALE)
.addCustomParam("aaa", "bbb")
.setCustomParam(mapOf("k1" to "v1", "k2" to "v2"))
.setContentId("test content")
.build())
GfpSdk.getUserProperties().clearCustomParameter();
GfpSdk.setUserProperties(GfpSdk.getUserProperties().buildUpon()
.yob(1987)
.country("KR")
.language("KO")
.gender(GenderType.MALE)
.addCustomParam("foo", "bar")
.setContentId("test content")
.build());
Key Methods of UserPropertiesBuilder
Method | Description |
---|---|
gender() | Sets the gender of the user. Default is null. |
yob() | Sets the year of birth of the user. Default is null. |
country() | Sets the user's country. Default is null. This is rarely used but can be passed to DSP if needed. |
language() | Sets the user's language. Instead of the device's default language, you can specify a different language. Default is null, and the input should follow ISO 639-1 codes. |
id() | Sets a user identifier for SDK log tracking. |
addCustomParam() | Global custom parameters (available from 6.0.0). |
setCustomParam() | Global custom parameters (available from 6.0.0). |
childDirectedTreatment() | Indicates whether the page or app targets children, as per the Children's Online Privacy Protection Act (COPPA) (available from 6.1.0). It can be left unset if not needed or unknown. |
underAgeOfConsent() | Indicates whether the ad request is for a user under the age of consent (available from 6.1.0). It can be left unset if not needed or unknown. |
contentId() | Sets the Content ID provided by the Naver API (available from 7.6.2). Please consult with your NAM representative before using this. |
Starting from NAM SDK 6.0.0, UserProperties.customParameter acts as a globally used user-defined parameter and can be merged with AdParam.customParameter used per ad request.
Reset SdkProperties and UserProperties
From NAM SDK 8.4.0, methods for resetting SdkProperties and UserProperties have been added. These can be used to reset user information when a logged-in user logs out or when SDK-related settings need to be cleared.
- Kotlin
- Java
GfpSdk.resetSdkProperties()
GfpSdk.resetUserProperties()
GfpSdk.resetSdkProperties();
GfpSdk.resetUserProperties();