Overview
Even though the Native player SDKs do not perform client-side macro replacement, you can manually append query string parameters for ad targeting. This can be done for either client-side or server-side ads.
To learn more about URL parameters, see the Ad Variables section of the Video Cloud SSAI Ad Config API document.
Client-side ads
You can provide custom values through URL parameters appended to the VMAP URL.
Android implementation
Ad targeting key/value pairs can be added to your ad tag URL in two ways:
-
Add your key/value pairs directly to the ad tag URL. Google IMA allows the addition of ad targeting key/value pairs using the
cust_params
parameter. For details, see Google's Add key-values to a master video ad tag document. -
Apply a Map of values to the ad tag URL using the
updateAdTargetingValues
method for theGoogleIMAComponent
.
For either approach, the key/value pairs are added to the ad tag URL in the ADS_REQUEST_FOR_VIDEO
event listener. The code sample below adds the key/value pairs using the updateAdTargetingValues
method for the GoogleIMAComponent
.
Here is the code to create a Map of key/value pairs, using the CUSTOM_FIELDS
property of the Video
object property of the ADS_REQUEST_FOR_VIDEO
event:
Here is a complete code sample for the ADS_REQUEST_FOR_VIDEO
event listener, which is added to the setup method for the Google IMA plugin:
iOS implementation
To append ad query parameters with the Native SDK for iOS, follow these steps:
-
Start with one of the client-side code sample for IMA advertising with the Brightcove Native SDK:
-
Append the URL query parameters to the VMAP URL before calling the IMA plugin. This can be done before the following methods:
Server-side ads
To provide custom values through URL parameters appended to the VMAP URL, follow these steps:
-
With an SSAI ad configuration id, retrieve a video object from the Brightcove catalog (Playback API). Learn how to create an ad configuration with the Implementing Server-Side Ads with the Native Player SDKs document.
A sample ad configuration looks like this:
-
In the jsonResponse from the call to the Playback API, examine the sources for the video object. Each source object will contain a VMAP property and a VMAP URL. Select and extract the VMAP URL.
-
Let’s say your ad URL looks like this:
If your ad URL has the above ad macros, then you will add these query parameters to the VMAP URLs with the appropriate values.
-
Append query parameters to the VMAP URL. In this example, the
macro in the ad url is replaced with the value
discos-enabled
, and themacro is replaced with the video id value.
- Process the video with the SSAI plugin.
-
For development details, see the following:
Android implementation
From the Playback API response, you can extract the appropriate VMAP source URL and append your query parameters. To do this, follow these steps:
- With an SSAI ad configuration id, retrieve a video object from the Brightcove catalog (Playback API). For details, see the Android implementation section of the Implementing Server-Side Ads with the Native Player SDKs document.
-
In the
Catalog
'sonVideo
callback method, select and extract the appropriate VMAP URL from theVideo
object's default source, using theSSAISourceSelector
. The source object returned should have a VMAP URL property. -
Append your query parameters to the VMAP URL:
-
Process the updated
Video
object with the SSAI plugin as follows:
Here is a complete code sample:
iOS implementation
From the Playback API response, you can extract the appropriate VMAP source URL and append your query parameters. To do this, follow these steps:
- With an SSAI ad configuration id, retrieve a video object from the Brightcove catalog (Playback API). For details, see the iOS implementation section of the Implementing Server-Side Ads with the Native Player SDKs document.
-
From the video object, select and extract the appropriate manifest or VMAP URL. From the playback service response, the jsonResponse (NSDictionary) contains the BCOVVideo object, which includes the sources which hold the URL to the VMAP document. Your code may look similar to this:
-
Append query parameters to the VMAP URL.
-
Process the modified URL with the SSAI plugin as follows: