Typically for a web application to play content with the Server-Side Ad Insertion (SSAI) service provided by MediaTailor, first it sends a session initialization HTTP request in order to receive the URL for the video stream with server-side ads inserted, as well as the ad tracking URL which is used for ad information polling. For example:
<!DOCTYPE html> <html lang="en"> ... <script> var session_init_url = ...; var xhr = new XMLHttpRequest(); xhr.open("POST", session_init_url, true); xhr.onload = function() { try { var response = JSON.parse(xhr.responseText); var manifest_url = new URL(response.manifestUrl, session_init_url).toString(); var tracking_url = new URL(response.trackingUrl, session_init_url).toString(); my_player.load(manifest_url); } catch (e) { console.error("Unable to parse session init response"); } }; xhr.send(JSON.stringify({ adsParams: {...} })); </script>
If the session initialization request is successful, the manifest URL for playing video (with server-side ads inserted) is converted to absolute URL and loaded into the player for content/ads presentation.
To an uninformed player or player data collector, the server-side inserted ads are indistinguishable from real contents under the same video stream. For a Datazoom collector to identify these ads and report ad data points accordingly, it must be given access to the ad tracking URL in order to derive the extra information needed for handling SSAI ads. This is discussed in the next section.
Attach the Ad Tracking URL
As in most Datazoom collector integrations, as soon as a player instance is created, a Datazoom collector context is created in order to collect data for this specific player. Now, we must perform one additional context method call to give the Datazoom collector context the access to the ad tracking URL.
The context method is named attachMediaTailorTrackingURL()
and it takes two parameters: the ad tracking URL and the desired ad information polling interval in seconds. It should be called as soon as session initialization is finished, as demonstrated in the following example:
my_player = createPlayer(); datazoom_context = datazoom.createContext(my_player); ... xhr.onload = function() { try { var response = JSON.parse(xhr.responseText); var manifest_url = new URL(response.manifestUrl, session_init_url).toString(); var tracking_url = new URL(response.trackingUrl, session_init_url).toString(); datazoom_context.attachMediaTailorTrackingURL(tracking_url, 10); my_player.load(manifest_url); } catch (e) { console.error("Unable to parse session init response"); } }; ...
As suggested by MediaTailor, the ad information polling should happen at least once per manifest duration.
That’s it. The Datazoom collector is now provided with the required access to gather SSAI ad related information.
Comments
0 comments
Article is closed for comments.