This page covers data collection for the Campaign ID variable. See Campaign ID for the corresponding reporting dimension.
The campaign ID variable identifies the ad campaign that the creative belongs to. Any string value (typically a campaign ID from your ad-server platform) is acceptable. Use the variable to roll up engagement across multiple creatives that share a campaign.
a.media.ad.campaignc_contextdata.a.media.ad.campaignWeb SDK
Set campaignID inside mediaCollection.advertisingDetails when calling sendEvent:
alloy("sendEvent", {
xdm: {
eventType: "media.adStart",
mediaCollection: {
advertisingDetails: {
name: "ad-2125",
campaignID: "fall-2024"
},
sessionID: "{sid}",
playhead: 0
}
}
});
Mobile SDK
Pass the campaign ID as a metadata key in the HashMap argument to trackEvent(AdStart). Use MediaConstants.AdMetadataKeys.CAMPAIGN_ID.
iOS (Swift)
var metadata: [String: String] = [:]
metadata[MediaConstants.AdMetadataKeys.CAMPAIGN_ID] = "fall-2024"
tracker.trackEvent(event: MediaEvent.AdStart, info: adObject, metadata: metadata)
Android (Kotlin)
val metadata = HashMap<String, String>()
metadata[MediaConstants.AdMetadataKeys.CAMPAIGN_ID] = "fall-2024"
tracker.trackEvent(Media.Event.AdStart, adObject, metadata)
Roku (BrightScript)
Set campaignID inside mediaCollection.advertisingDetails when calling sendMediaEvent for media.adStart:
m.aepSdk.sendMediaEvent({
"xdm": {
"eventType": "media.adStart",
"mediaCollection": {
"advertisingDetails": {
"name": "ad-2125",
"campaignID": "fall-2024"
},
"playhead": 0
}
}
})
Media Edge API
Call the adStart endpoint with campaignID inside mediaCollection.advertisingDetails:
{
"events": [{
"xdm": {
"eventType": "media.adStart",
"mediaCollection": {
"advertisingDetails": {
"name": "ad-2125",
"length": 15,
"playerName": "Freewheel",
"podPosition": 0,
"campaignID": "fall-2024"
},
"sessionID": "{sid}",
"playhead": 0
}
}
}]
}
Media SDK
Pass the campaign ID in the contextData object using ADB.Media.AdMetadataKeys.CampaignId:
var contextData = {};
contextData[ADB.Media.AdMetadataKeys.CampaignId] = "fall-2024";
tracker.trackEvent(ADB.Media.Event.AdStart, adInfo, contextData);
Media Collection API
Include media.ad.campaignId in the params object:
{
"playerTime": { "playhead": 0, "ts": 1699523820000 },
"eventType": "adStart",
"params": {
"media.ad.campaignId": "fall-2024"
}
}
See the Media Collection API events reference for the full request structure.