# Google Ad Manager on VOD

With Google Ad Manager 360, Google decides which ads fill the breaks of your on-demand assets. Google assembles the ads for each break into a pod, and the pod plays when the viewer reaches the break. Use this workflow when you sell your VOD inventory through Google Ad Manager 360, and to reach platforms that need server-side ad insertion.

|                | Google Ad Manager on VOD                                                   |
| -------------- | -------------------------------------------------------------------------- |
| Delivery mode  | Server-guided (SGAI), server-side (SSAI), or both                          |
| Ad decisioning | Google Ad Manager, per viewer session                                      |
| Break creation | Scheduled at positions in the asset, or detected from the ad markers in it |
| Your app needs | The OptiView Ads SDK; on Web also Google's IMA DAI SDK                     |

Contact your Dolby OptiView account team to enable Google Ad Manager on your VOD channels.

## Choose a delivery mode

| Delivery mode | How it works                                                                                                       | Use it for                                                                                          |
| ------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| Server-guided | Google decisions the pods; the SDK inserts them at the break positions of your untouched asset.                    | Web, mobile, and most connected TV apps. Required for the double box, L-shape, and overlay layouts. |
| Server-side   | Google stitches the ads for the asset's breaks into the on-demand stream, and the player plays the stitched asset. | Platforms where a client-side SDK is not an option, such as Roku and older connected TV devices.    |

One channel can serve both: the channel steers the [delivery mode per device](https://optiview.dolby.com/docs/ads/workflows.md#hybrid-ad-insertion-sgai-and-ssai), and the SDK picks it up from the Break Manifest.

## Before you start

* The [Google Ad Manager prerequisites](https://optiview.dolby.com/docs/ads/integrations/google.md) — network code and service account — are in place for your organization.
* A [VOD channel](https://optiview.dolby.com/docs/ads/workflows/vod.md#set-up-a-vod-channel), connected to Google. The examples use the `mediatime` timebase.
* The OptiView Ads SDK in your app: [Web](https://optiview.dolby.com/docs/ads/player-integration/optiview-ads-sdk/web.md), [Android](https://optiview.dolby.com/docs/ads/player-integration/optiview-ads-sdk/android.md), [iOS](https://optiview.dolby.com/docs/ads/player-integration/optiview-ads-sdk/ios.md), or [React Native](https://optiview.dolby.com/docs/ads/player-integration/optiview-ads-sdk/react-native.md).

## Schedule a break

A Google break carries a [vendor asset](https://optiview.dolby.com/docs/ads/concepts/breaks.md#vendor-assets) with `vendor` set to `gam` and `vendorParameters.type` set to `pod`. Google performs the decisioning, so the asset needs no URI. On a `mediatime` channel, `start` is the position in the asset, in seconds:

```bash
curl -X POST 'https://us.ads.optiview.dolby.com/api/v1/channels/<channel-id>/breaks' \
  -u "$ADS_API_KEY:$ADS_API_SECRET" \
  -H 'Content-Type: application/json' \
  -H 'X-Org-ID: <org-id>' \
  -d '{
    "start": 600,
    "duration": 60,
    "controls": { "snapback": true },
    "variant": {
      "format": "single",
      "assets": [
        {
          "type": "vendor",
          "vendor": "gam",
          "vendorParameters": { "type": "pod" },
          "assetParameters": {
            "description_url": "https://www.example.com/movies/the-big-match.html",
            "plcmt": "1"
          }
        }
      ]
    }
  }'
```

### Detect the breaks

Instead of scheduling every break, add the asset as an [origin](https://optiview.dolby.com/docs/ads/concepts/origins.md) and configure a [marker rule](https://optiview.dolby.com/docs/ads/concepts/marker-detection.md) whose [template](https://optiview.dolby.com/docs/ads/concepts/templates.md) holds the Google vendor asset. Every matching ad marker in the asset becomes a break at its position.

## How the break plays

* **Server-guided:** the SDK fetches the channel's [Break Manifest](https://optiview.dolby.com/docs/ads/concepts/break-manifest.md) once when the session starts, and inserts Google's pods at the break positions as the viewer reaches them.
* **Server-side:** Google stitches the ads into the asset, and the player plays the stitched stream.
* Ads are decisioned per viewer session rather than per break moment, because every viewer watches from their own position: there is no audience-wide peak at a break start.
* With `snapback`, a viewer who seeks past a break is taken back to the break first. See [Seeking and snapback](https://optiview.dolby.com/docs/ads/workflows/vod.md#seeking-and-snapback).

## What your app needs

The SDK reads the Google settings — your network code and the channel's Google asset key — from the channel's Break Manifest, and starts the Google stream session automatically when the session starts. You do not configure them in the app, so your app and the backend always agree on which Google stream the ads belong to.

| Platform     | Requirement                                                                                                                                                                                                                                      |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Web          | Load Google's IMA DAI SDK on the page, before your application script (see below).                                                                                                                                                               |
| Android      | Nothing extra: the SDK runtime includes the Google IMA SDK.                                                                                                                                                                                      |
| iOS and tvOS | Nothing extra: the runtime pod includes the Google IMA SDK. With Swift Package Manager, add the Google IMA packages as described in [iOS](https://optiview.dolby.com/docs/ads/player-integration/optiview-ads-sdk/ios.md#swift-package-manager). |
| React Native | Nothing extra: the native SDKs include the Google IMA SDK.                                                                                                                                                                                       |

On Web, add the IMA DAI loader to your page:

```html
<script src="https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js"></script>
```

If your channel also has VAST breaks, load `ima3.js` as well; the two scripts work side by side.

### Server-side sessions

When the channel steers a device to SSAI, the SDK requests the stitched stream from Google and loads it into your content player instead of your original stream URL. Your app keeps the same integration and starts the session with the same Break Manifest URL. On Web, use a content player adapter that exposes its video element, such as the HLS.js, Shaka, or native video adapter. In a server-side session, the SDK still plays the [event-triggered breaks](https://optiview.dolby.com/docs/ads/concepts/breaks.md#event-based-triggers) — pre-roll, pause, and post-roll — on the device.

## Ad targeting parameters

For Google, `assetParameters` are sent as Google [ad tag parameters](https://support.google.com/admanager/answer/10678356) (`adTagParameters`). As a rule of thumb:

* Set the values that describe your content on the break, such as `description_url` and `plcmt`. See [Required Google parameters](https://optiview.dolby.com/docs/ads/integrations/google/pod-serving.md#required-google-parameters).
* Set the values that depend on the playback environment in the SDK, such as `vpa` and `vpmute` and, in apps, the [device and app identity parameters](https://optiview.dolby.com/docs/ads/integrations/google/pod-serving.md#additional-parameters-for-app-inventory).

When the same key is set in both places, the value on the break wins. See [Ad targeting parameters](https://optiview.dolby.com/docs/ads/how-to-guides/ad-tag-parameters.md) for the merge rules and platform examples.

## Troubleshooting

| Diagnostic               | What it means                                                                                   | What to do                                                                                    |
| ------------------------ | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `DA-GAM-CONFIG-RESOLVED` | Informational: the Google stream session uses the network code and asset key in the diagnostic. | Check that they match your Google stream.                                                     |
| `DA-GAM-CONFIG-MISSING`  | The Break Manifest carries Google breaks but no usable Google configuration.                    | Check that the channel is connected to Google.                                                |
| `DA-GAM-SESSION-FAILED`  | The Google stream session could not be started.                                                 | On Web, load `ima3_dai.js` on the page. Otherwise, check the error message in the diagnostic. |

Breaks that fail in the backend, for example because Google could not decision them in time, end up in the `ERROR` state and never reach the SDK. See [Troubleshooting](https://optiview.dolby.com/docs/ads/integrations/google/pod-serving.md#troubleshooting) on the Google Pod Serving integration page for the possible reasons.

## Related resources

| Resource                                                                                             | Description                                                         |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| [VOD](https://optiview.dolby.com/docs/ads/workflows/vod.md)                                          | VOD channels: timebase, seeking, and delivery modes.                |
| [Google Ad Manager](https://optiview.dolby.com/docs/ads/integrations/google.md)                      | Organization-level prerequisites: network code and service account. |
| [Ad targeting parameters](https://optiview.dolby.com/docs/ads/how-to-guides/ad-tag-parameters.md)    | Passing ad tag parameters to Google.                                |
| [Your ad server (VAST) on VOD](https://optiview.dolby.com/docs/ads/workflows/vod/vast.md)            | Play VAST tags from your own ad server, without Google Ad Manager.  |
| [Google Ad Manager on live](https://optiview.dolby.com/docs/ads/workflows/live/google-ad-manager.md) | The same workflow for live streams.                                 |
