# Google DAI

Google DAI (Dynamic Ad Insertion) is the server-side (SSAI) delivery mode for Google Ad Manager: Google stitches the ads directly into the media stream that players receive.

## What is Google DAI?

With server-side ad insertion, the ad content is inserted into the video stream itself before it reaches the player. The player plays one continuous stream and needs no ad-insertion logic of its own.

Use Google DAI for platforms that cannot run the server-guided [Google Pod Serving](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google/pod-serving.md) flow — such as Roku and older connected TV devices. On platforms that support pod serving, prefer pod serving: it keeps the media stream untouched and enables the advanced break [layouts](https://docs-preview.optiview.dolby.com/pr-981/ads/concepts/breaks.md#layouts).

Before you start, make sure the [Google Ad Manager prerequisites](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google.md) are configured for your organization.

## Configure Google Ad Manager

### Live streams

A live stream in Google Ad Manager connects your linear stream to Google's dynamic ad insertion. Create one under **Video > Live streams > New live stream** and select **Linear** as the type. The live stream provides the **DAI asset key** that identifies it, and it carries the **content stream URL** and the **master ad tag**. Its streaming format (HLS or DASH) is the format of the stream Google delivers to players, so choose the format of the channel origin it ingests.

### Content stream URL and the Dolby Ads Proxy

Google DAI needs to see the ad break cues inside the stream to know where to insert ads. Because OptiView Ads schedules breaks without modifying your origin's stream, the **Dolby Ads Proxy** sits between your CDN and Google DAI: it passes your HLS stream through unchanged and inserts the ad break cue metadata (`EXT-X-DATERANGE` tags) for upcoming breaks.

```text
Customer origin ──▶ Customer CDN ──▶ Dolby Ads Proxy ──▶ Google DAI
```

Use the Dolby Ads Proxy URL for your channel's origin as the live stream's content stream URL:

```text
https://us.ads.optiview.dolby.com/proxy/v1/{organization-id}/origins/{origin-id}/google/index.m3u8
```

For the EU region, use `https://eu.ads.optiview.dolby.com/proxy/v1/`. Your account team can help you determine the exact URL for your setup.

### Master ad tag

The master ad tag is the ad tag URL configured on the live stream. It references your network code and the ad unit to target, so when Google inserts an ad break it knows which line items and creatives are eligible. See [Configure Google Ad Manager](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google/pod-serving.md#configure-google-ad-manager) on the Google Pod Serving page for how ad units, orders, line items, and creatives fit together — the same campaign setup applies to Google DAI.

### Server-side beaconing

Besides the stitched stream that a player requests through Google's IMA SDK, Google serves every linear live stream as a **server-side beaconing (SSB)** stream: a stream URL that any HLS or DASH player loads directly, without the IMA SDK. Ad Manager tracks the ads from the stream requests and reports estimated ad metrics. Google makes live linear streams available over SSB without a separate setting on the live stream; check Google's [SSB documentation](https://support.google.com/admanager/answer/7299051) for the features an SSB stream supports before you use it.

OptiView Ads delivers the SSB stream of a live stream to players only when you enable `ssb` on its asset in the channel integration (see below). Players switch to it when they cannot insert ads themselves — see [Server-side beaconing streams](#server-side-beaconing-streams).

## Configure your channel

Enable Google DAI on your [channel](https://docs-preview.optiview.dolby.com/pr-981/ads/concepts/channels.md) by creating a channel integration that lists the Google live streams of the channel in `daiAssets`, one entry per live stream:

```json
{
  "type": "SSAI",
  "vendor": "GOOGLE",
  "daiAssets": [
    {
      "assetKey": "si2XCsdWTB-Cz9zWftSCoQ",
      "originId": "primary-hls",
      "ssb": {
        "assetParameters": {
          "cust_params": "delivery=ssb"
        }
      }
    }
  ]
}
```

| Property              | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                             |
| --------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `assetKey`            | Yes      | The DAI asset key of the Google live stream. Ad breaks are announced to this live stream. A DAI asset key can only be used on one channel within your organization.                                                                                                                                                                                                                                                     |
| `originId`            | No       | The [origin](https://docs-preview.optiview.dolby.com/pr-981/ads/concepts/origins.md) of the channel that the live stream ingests. It must be an `HLS` or `DASH` origin of the channel; any other value is rejected with `400` and reason `DAI_ASSET_ORIGIN_INVALID`. Its type and DRM configuration describe the SSB stream. When omitted, see [Which origin backs the SSB stream](#which-origin-backs-the-ssb-stream). |
| `ssb`                 | No       | Enables the SSB stream of the live stream in the Break Manifest. Use an empty object (`"ssb": {}`) to enable it without extra parameters. Without `ssb`, players receive no SSB stream for this live stream.                                                                                                                                                                                                            |
| `ssb.assetParameters` | No       | Ad tag parameters sent on the SSB stream request only, merged over the integration's `assetParameters`, for example `cust_params` targeting that marks SSB sessions. Same format and macros as other [ad tag parameters](https://docs-preview.optiview.dolby.com/pr-981/ads/how-to-guides/ad-tag-parameters.md).                                                                                                        |

`daiAssets` holds at least one entry and must not repeat an `assetKey`. An update that includes `daiAssets` replaces the list as a whole. The integration's `assetParameters` apply to every live stream in the list.

## Schedule a break

Scheduling works exactly like the pod serving flow: create a [break](https://docs-preview.optiview.dolby.com/pr-981/ads/concepts/breaks.md) with a vendor asset and optional `assetParameters`. See [Schedule a pod break](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google/pod-serving.md#schedule-a-pod-break) — including the [required Google parameters](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google/pod-serving.md#required-google-parameters).

## How the Google DAI flow works

1. A break is created and, ahead of its start (within the [look-forward time](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google.md#look-forward-time)), OptiView Ads announces it to Google using the DAI asset keys in the integration's `daiAssets`.
2. When the break's start approaches, the Dolby Ads Proxy inserts the break's cue metadata (`EXT-X-DATERANGE` tags carrying the SCTE-35 markers) into the stream served to Google DAI. The break becomes `SIGNALED` once its cue is inserted into the stream.
3. Google DAI detects the cue, matches it with the announced break, and stitches the decisioned ads into the stream delivered to players.

### Validate your stream

You can validate the end-to-end setup with Google's [DAI SDK for HTML5 Video Suite Inspector](https://googleads.github.io/googleads-ima-html5-dai/vsi/). Enter your network code and DAI asset key to play your live stream through Google DAI and inspect the inserted ad breaks and the ad requests Google makes.

## Server-side beaconing streams

For each `daiAssets` entry, the [Break Manifest](https://docs-preview.optiview.dolby.com/pr-981/ads/concepts/break-manifest.md#google-ad-manager-vendor-configuration) carries an `ssai` entry with the asset key. When the asset has `ssb` enabled and an origin backs it, the `ssai` entry also carries the SSB stream:

| Field             | Value                                                                                                                                                                                                                        |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `uri`             | Google's SSB stream URL for the asset key: `https://pubads.g.doubleclick.net/ssai/event/{assetKey}/master.m3u8` for an HLS origin, `https://pubads.g.doubleclick.net/ssai/event/{assetKey}/manifest.mpd` for a DASH origin.  |
| `format`          | `hls` or `dash`, the type of the origin.                                                                                                                                                                                     |
| `assetParameters` | The asset's `ssb.assetParameters`, if any.                                                                                                                                                                                   |
| `drm`             | The origin's DRM configuration: its `integration` and its FairPlay, Widevine, and PlayReady license URLs. Google leaves the content encryption untouched, so the SSB stream uses the origin's DRM. Absent for clear origins. |

Players use the first `ssai` entry, so list the live stream that players should use first in `daiAssets`.

### Which origin backs the SSB stream

Google passes your content through unchanged, so the SSB stream has the same format and the same DRM as the stream that Google ingests. OptiView Ads takes both from one of the channel's origins:

* If you tell OptiView Ads which origin the Google live stream ingests, it uses that origin.
* Otherwise, it uses the first enabled HLS or DASH origin of the channel in priority order. When an HLS and a DASH origin share the same priority, the HLS origin is used.

### What the OptiView Ads SDK does with the SSB stream

The SDK uses the SSB stream when it cannot insert ads itself on the current output, such as while the viewer plays the channel over AirPlay. It loads the stream on the content player with the DRM configuration and the ad tag parameters — the parameters from your app, then the integration's `assetParameters`, then `ssb.assetParameters`, a later source winning for the same key. While the SSB stream plays, the stream carries the ads, so the SDK does not play the breaks from the Break Manifest. When playback returns to the device, the SDK restores your content stream and the delivery mode of the session. Without an SSB stream it can play, the SDK leaves external playback to your app.

## Troubleshooting

A break that fails ends up in the `ERROR` state with an `errorReason` — see [Troubleshooting](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google/pod-serving.md#troubleshooting) on the Google Pod Serving page for the possible reasons.

Common Google DAI-specific issues relate to the ad tag parameters on the ad requests:

* **Missing required parameters.** Google requires `description_url` for ad serving, and `plcmt`, `vpa`, and `vpmute` for programmatic monetization. For app inventory, `rdid`, `is_lat`, `idtype`, `an`, and `msid` are also required, and `wta` is highly recommended. See [Required Google parameters](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google/pod-serving.md#required-google-parameters).
* **Invalid `description_url` format.** The value must be URL-encoded exactly once — a double-encoded value (for example `https%253A%252F%252F...`) is invalid. Supply the plain URL and verify the encoding in the final ad request.

Use the [Video Suite Inspector](#validate-your-stream) to inspect the ad requests and confirm the parameters Google receives.

## Related resources

| Resource                                                                                                    | Relationship                                                                 |
| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [Google Ad Manager](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google.md)              | The prerequisites shared by both Google delivery modes.                      |
| [Google Pod Serving](https://docs-preview.optiview.dolby.com/pr-981/ads/integrations/google/pod-serving.md) | Server-guided (SGAI) delivery, preferred where supported.                    |
| [Channels](https://docs-preview.optiview.dolby.com/pr-981/ads/concepts/channels.md)                         | Hold the Google DAI channel integration.                                     |
| [Origins](https://docs-preview.optiview.dolby.com/pr-981/ads/concepts/origins.md)                           | The stream origins proxied by the Dolby Ads Proxy; they back the SSB stream. |
| [Breaks](https://docs-preview.optiview.dolby.com/pr-981/ads/concepts/breaks.md)                             | Carry the vendor asset that Google uses to make ad decisions.                |
| [API reference](https://docs-preview.optiview.dolby.com/pr-981/ads/api.md)                                  | Creating and managing channels, breaks, and integrations programmatically.   |
