init
Initializes the Storyteller GAM module with the necessary configuration for ad requests.
This method sets up the GAM module with dynamic ad unit resolution, custom native template IDs, and client-specific key-value pairs for ad targeting. For detailed examples and setup, see the Storyteller Ads Documentation.
Parameters
A lambda function that accepts a StorytellerAdRequestInfo object and returns the appropriate ad unit ID (String) for the current ad request context. This allows for flexible ad unit determination, for instance, using different ad units for Stories versus Clips, or based on other criteria within StorytellerAdRequestInfo. Example: { storytellerAdRequestInfo -> when (storytellerAdRequestInfo) { is StorytellerAdRequestInfo.StoriesAdRequestInfo -> "/your/stories/ad_unit_id" else -> "/your/clips/ad_unit_id" } }
An optional StorytellerCustomNativeTemplateIds object. This should be provided if you are using Custom Native Ads configured with the Storyteller Delivery team. It holds the template IDs for Stories and Clips ads. If you only use one type (e.g., only Stories), you only need to supply the relevant ID. Example: StorytellerCustomNativeTemplateIds(stories = "12345", clips = "67890")
A lambda function that returns a Map of String to String. These are custom key-value pairs that will be passed to the Google Ad Manager SDK for ad targeting. The Storyteller GAM SDK includes a default set of KVPs; these client-provided pairs will be merged with the default ones. Note that the SDK does not inherit KVPs set elsewhere in your application. Example: { mapOf("targetingKey" to "targetingValue") }
An optional lambda function for bottom banner ads in clips. This is separate from the main ad unit to allow different targeting for bottom banner placements. If not provided, bottom banner ads will not be requested. Only 300x50 and 320x50 ad sizes are supported. Example: { adRequestInfo -> "/your/bottom_banner/ad_unit_id" }
This overload preserves the original GAM initialization API and does not configure PPID. Calling it replaces the module configuration and clears any PPID provider configured by the PPID overload. Use the overload with publisherProvidedId when PPID targeting is needed.
Initializes the Storyteller GAM module with a Publisher Provided ID provider for GAM audience-targeted ad requests.
Parameters
A lambda function that accepts a StorytellerAdRequestInfo object and returns the appropriate ad unit ID (String) for the current ad request context.
An optional StorytellerCustomNativeTemplateIds object for Storyteller Delivery custom native ad template IDs.
A lambda function that returns custom key-value pairs for GAM targeting.
An optional lambda function for bottom banner ads in clips.
A lambda function that returns a Publisher Provided ID for the current GAM request. This value is passed through AdManagerAdRequest.Builder.setPublisherProvidedId, not as a custom key-value pair. Leading and trailing whitespace is trimmed; return null or a blank value to omit it. The value is only sent when Storyteller.eventTrackingOptions has ad tracking enabled.