Site ID

This page covers data collection for the Site ID variable. See Site ID for the corresponding reporting dimension.

The site ID variable identifies the ad site. Any string value (typically an ID from your ad-server platform) is acceptable.

Property
Value
Context data variable
a.media.ad.site
XDM collection field
xdm.mediaCollection.advertisingDetails.siteID
Audience Manager trait
c_contextdata.a.media.ad.site
Required
No
Sent with
Ad start, ad close
Web SDK

Set siteID inside xdm.mediaCollection.advertisingDetails when calling sendEvent:

code language-javascript
alloy("sendEvent", {
  xdm: {
    eventType: "media.adStart",
    mediaCollection: {
      advertisingDetails: {
        name: "ad-2125",
        siteID: "site-42"
      },
      sessionID: "{sid}",
      playhead: 0
    }
  }
});
iOS

Pass the site ID as a metadata key in the HashMap argument to trackEvent(AdStart). Use MediaConstants.AdMetadataKeys.SITE_ID.

code language-swift
var metadata: [String: String] = [:]
metadata[MediaConstants.AdMetadataKeys.SITE_ID] = "site-42"

tracker.trackEvent(event: MediaEvent.AdStart, info: adObject, metadata: metadata)
Android

Pass the site ID as a metadata key in the HashMap argument to trackEvent(AdStart). Use MediaConstants.AdMetadataKeys.SITE_ID.

code language-kotlin
val metadata = HashMap<String, String>()
metadata[MediaConstants.AdMetadataKeys.SITE_ID] = "site-42"

tracker.trackEvent(Media.Event.AdStart, adObject, metadata)
Roku Edge

Set siteID inside xdm.mediaCollection.advertisingDetails when calling sendMediaEvent for media.adStart:

code language-brightscript
m.aepSdk.sendMediaEvent({
    "xdm": {
        "eventType": "media.adStart",
        "mediaCollection": {
            "advertisingDetails": {
                "name": "ad-2125",
                "siteID": "site-42"
            },
            "playhead": 0
        }
    }
})
Media Edge API

Call the adStart endpoint with siteID inside xdm.mediaCollection.advertisingDetails:

code language-json
{
  "events": [{
    "xdm": {
      "eventType": "media.adStart",
      "mediaCollection": {
        "advertisingDetails": {
          "name": "ad-2125",
          "length": 15,
          "playerName": "Freewheel",
          "podPosition": 0,
          "siteID": "site-42"
        },
        "sessionID": "{sid}",
        "playhead": 0
      }
    }
  }]
}

Legacy implementation types (Analytics-only)

Media SDK JS 3.x

Pass the site ID in the contextData object using ADB.Media.AdMetadataKeys.SiteId:

code language-javascript
var contextData = {};
contextData[ADB.Media.AdMetadataKeys.SiteId] = "site-42";

tracker.trackEvent(ADB.Media.Event.AdStart, adInfo, contextData);
Chromecast

Set the site ID using ADBMobile.media.AdMetadataKeys.SITE_ID in the standard ad metadata object:

code language-javascript
var adInfo = ADBMobile.media.createAdObject("Ford F-150", "ad-2125", 1, 30);
var standardAdMetadata = {};
standardAdMetadata[ADBMobile.media.AdMetadataKeys.SITE_ID] = "site-42";
adInfo[ADBMobile.media.MediaObjectKey.StandardAdMetadata] = standardAdMetadata;
ADBMobile.media.trackEvent(ADBMobile.media.Event.AdStart, adInfo, null);
Roku 2.x

Set the site ID using MEDIA_AdMetadataKeySITE_ID in the standard ad metadata object:

code language-brightscript
adb = ADBMobile()
adInfo = adb_media_init_adinfo("Ford F-150", "ad-2125", 1, 30.0)

standardAdMetadata = {}
standardAdMetadata[adb.MEDIA_AdMetadataKeySITE_ID] = "site-42"
adInfo[adb.MEDIA_STANDARD_AD_METADATA] = standardAdMetadata

adb.mediaTrackEvent(adb.MEDIA_AD_START, adInfo)
Media Collection API

Include media.ad.siteId in the params object:

code language-json
{
  "playerTime": { "playhead": 0, "ts": 1699523820000 },
  "eventType": "adStart",
  "params": {
    "media.ad.siteId": "site-42"
  }
}

See the Media Collection API events reference for the full request structure.

recommendation-more-help
media-analytics-help