Storyteller Gam Module
The Storyteller GAM (Google Ad Manager) Module is responsible for integrating Google Ad Manager ads into the Storyteller SDK. It allows for fetching and displaying ads from GAM within Storyteller Stories and Clips.
To use this module, you first need to obtain an instance using StorytellerGamModule.getInstance. Then, initialize it by calling the init method, providing the necessary configuration.
The init method requires the following parameters:
adUnit: A lambda function that takes a StorytellerAdRequestInfo object and returns the ad unit ID as a String. This allows for dynamic ad unit selection based on the content being viewed. For example, you can use different ad units for Stories and Clips. e.g.,adUnit = { storytellerAdRequestInfo : StorytellerAdRequestInfo -> when (storytellerAdRequestInfo) { is StorytellerAdRequestInfo.StoriesAdRequestInfo -> "/your/stories/adunit" else -> "/your/clips/adunit" } }templateIds: An optional CustomNativeTemplateIds object. If you have set up Custom Native Ads with the Storyteller Delivery team, you need to supply their IDs here. If you are only using Stories (but not Clips) or vice-versa, it is only necessary to supply the relevant property of this object. e.g.,templateIds = CustomNativeTemplateIds(stories = "yourStoryTemplateId", clips = "yourClipTemplateId")keyValuePairs: An optional lambda function that returns aMap<String, String>of custom key-value pairs. The Storyteller GAM SDK passes a default set of KVPs to GAM for targeting. If you have additional parameters for targeting, they should be passed here. The SDK will not inherit KVPs set elsewhere in your app. e.g.,keyValuePairs = { mapOf("customKey" to "customValue") }
After initialization, the instance of StorytellerGamModule must be added to the Storyteller.modules list:
val storytellerGamModule = StorytellerGamModule.getInstance(applicationContext).apply {
init(
adUnit = { storytellerAdRequestInfo -> "/33813572/storyteller" }, // Replace with your ad unit logic
templateIds = CustomNativeTemplateIds("12102683", "12269089"), // Replace with your template IDs if any
keyValuePairs = { emptyMap() } // Replace with your KVPs if any
)
}
Storyteller.modules = listOf(storytellerGamModule)This module handles the fetching of ads by making requests to Google Ad Manager. It supports native ads, banner ads, and custom format ads. It also manages ad events like clicks and impressions.
For more information on integrating ads, see the Storyteller Ads Documentation.
Parameters
The application context.
See also
Constructors
Functions
Initializes the Storyteller GAM module with the necessary configuration for ad requests.