

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 广告追踪活动时机
<a name="ad-reporting-client-side-ad-tracking-schema-activity-timing"></a>

在客户端报告中，玩家必须精确地发出跟踪事件（信标）。使用 MediaTailor 客户端跟踪架构，您可以确保每种可用性、广告、配套事件、叠加层事件和跟踪事件、时间和持续时间信息均以不同的形式存在。

使用以下 MediaTailor 键/值对让玩家准确协调广告事件活动（例如跟踪事件）和播放位置：
+ [startTime](ad-reporting-client-side-ad-tracking-schema.md#property-starttime) 
+  [startTimeInSeconds](ad-reporting-client-side-ad-tracking-schema.md#property-starttimeinseconds) 
+  [adProgramDateTime](ad-reporting-client-side-ad-tracking-schema.md#property-adprogramdatetime) 
+  [adID](ad-reporting-client-side-ad-tracking-schema.md#property-adid)/[eventId](ad-reporting-client-side-ad-tracking-schema.md#property-eventid) 

HLS 和 DASH 以`startTimeInSeconds`不同的方式实现`startTime`和的价值：
+ HLS-这些`startTime`值是相对于播放会话开始时间的。播放会话的开始时间定义为零时间。广告`startTime`是有效期之前所有`EXT-INF`细分持续时间的累积值的总和。广告或跟踪事件所在区段的媒体序列号也对应于客户端跟踪`eventId`响应中的`adId`或。
+ DASH：
  + 实时/动态清单-这些`startTime`值是相对于 DASH 清单`MPD@availabilityStartTime`的值。`MPD@avaibilityStartTime`是所有消耗直播的 MediaTailor 会话的计时锚点。
  + VOD/Static 清单-这些`startTime`值是相对于播放会话开始时间的。播放会话的开始时间定义为零时间。Avail中的每个广告都包含在自己的`Period`元素中。该`Period`元素的`@start`属性值与客户端跟踪负载中的`startTime`值相同。`PeriodId`也对应于客户端跟踪响应`eventId`中的`adId`或。

**Example HLS：**  
在以下示例中， MediaTailor 会话已启动，以下清单是第一个提供给客户端的清单：  

```
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:4603263
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-PROGRAM-DATE-TIME:2023-05-03T21:24:23.295678Z
#EXTINF:4.010667,
https://123.cloudfront.net/out/v1/index_1_34.ts
#EXT-X-PROGRAM-DATE-TIME:2023-05-03T21:24:27.306345Z
#EXTINF:4.010667,
https://123.cloudfront.net/out/v1/index_1_35.ts
#EXT-X-PROGRAM-DATE-TIME:2023-05-03T21:24:31.317012Z
#EXTINF:4.010667,
https://123.cloudfront.net/out/v1/index_1_36.ts
#EXT-X-PROGRAM-DATE-TIME:2023-05-03T21:24:35.327679Z
#EXTINF:4.010667,
https://123.cloudfront.net/out/v1/index_1_37.ts
#EXT-X-PROGRAM-DATE-TIME:2023-05-03T21:24:39.338346Z
#EXTINF:2.538667,
https://123.cloudfront.net/out/v1/index_1_38.ts
#EXT-X-DISCONTINUITY
#EXT-X-KEY:METHOD=NONE
#EXT-X-PROGRAM-DATE-TIME:2023-05-03T21:24:41.453Z
#EXTINF:2.0,
https://123.cloudfront.net/tm/asset_1080_4_8_00001.ts
#EXT-X-PROGRAM-DATE-TIME:2023-05-03T21:24:43.453Z
#EXTINF:2.0,
https://123.cloudfront.net/tm/asset_1080_4_8_00002.ts
#EXT-X-PROGRAM-DATE-TIME:2023-05-03T21:24:45.453Z
#EXTINF:2.0,
https://123.cloudfront.net/tm/asset_1080_4_8_00003.ts
```
在客户端跟踪 JSON 负载中，以下值适用：  
+  `startTime`: `"PT18.581355S"` 
+  `startTimeInSeconds`: `18.581` 
+  `availProgramDateTime`: `"2023-05-03T21:24:41.453Z"` 
+  `adId`: `4603269` 

**Example DASH：**  
在以下示例中，会 MediaTailor 话在清单中获得中间滚动。请注意，第二个时段（即广告时段）的`@start`属性值具有相对于该`MPD@availabilityStartTime`值的值。此值是 MediaTailor 写入所有会话的客户端跟踪响应`startTime`字段的值。  

```
<?xml version="1.0" encoding="UTF-8"?>
<MPD availabilityStartTime="2022-10-05T19:38:39.263Z" minBufferTime="PT10S" minimumUpdatePeriod="PT2S" profiles="urn:mpeg:dash:profile:isoff-live:2011" publishTime="2023-05-03T22:06:48.411Z" suggestedPresentationDelay="PT10S" timeShiftBufferDepth="PT1M30S" type="dynamic" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:scte35="urn:scte:scte35:2013:xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd">
    <BaseURL>https://123.channel-assembly.mediatailor.us-west-2.amazonaws.com/v1/channel/my-channel/</BaseURL>
    <Location>https://123.cloudfront.net/v1/dash/94063eadf7d8c56e9e2edd84fdf897826a70d0df/MediaTailor-Live-HLS-DASH/channel/channel1/dash.mpd?aws.sessionId=794a15e0-2a7f-4941-a537-9d71627984e5</Location>
    <Period id="1683151479166_1" start="PT5042H25M59.903S" xmlns="urn:mpeg:dash:schema:mpd:2011">
        <BaseURL>https://123.cloudfront.net/out/v1/f1a946be8efa45b0931ea35c9055fb74/ddb73bf548a44551a0059c346226445a/eaa5485198bf497284559efb8172425e/</BaseURL>
        <AdaptationSet ...>
            ...
        </AdaptationSet>
    </Period>
    <Period id="1683151599194_1_1" start="PT5042H27M59.931S">
        <BaseURL>https://123.cloudfront.net/tm/94063eadf7d8c56e9e2edd84fdf897826a70d0df/fpc5omz5wzd2rdepgieibp23ybyqyrme/</BaseURL>
        <AdaptationSet ...>
            ...
        </AdaptationSet>
    </Period>
</MPD>
```
在客户端跟踪 JSON 负载中，以下值适用：  
+  `startTime`: `"PT5042H27M59.931S"` 
+  `startTimeInSeconds`: `18152879.931` 
+  `availProgramDateTime`: *null* 
+  `adId`: `1683151599194_1_1` 