Set Campaign Mapping
set_campaign_mappingReplace a model's campaign mapping to control which channel each campaign counts toward. Provide campaign IDs or name patterns; conflicts and unmapped campaigns are reported.
Instructions
Replace the model's campaign map: which model channel each campaign counts towards.
Each row is {platform, campaign_id | name_pattern, channel, valid_from?, valid_to?}: exactly
one of campaign_id (the platform's id, exact) or name_pattern (a glob on the campaign
name, e.g. "YouTube*", case-insensitive); channel must be one of the model's channel names
(as in get_model_results); dates are ISO and optional (open-ended when absent). An exact-id
row beats any pattern row. The whole map is replaced by rows; send every row you want kept.
Refused (422, code campaign_map_invalid, nothing saved) when a channel is not the model's
(the error names the closest one), when a campaign would count towards two channels on any
date (two exact rows on one campaign with overlapping dates, or two patterns matching one
campaign with overlapping dates; conflicts lists them), or when a row is malformed.
Returns the map report: {map, unmapped: [{platform, campaign_id, campaign_name, spend,
first_seen, last_seen, platform_channel_type, suggested_channel}], conflicts: [], drift:
[{channel, campaign_spend, model_spend, ratio, over_tolerance, campaigns}], tolerance,
currency, currency_mismatch, window, channels}. drift compares the spend of the campaigns
mapped to each channel with the model's own spend for that channel over the dates both have;
over_tolerance is a WARNING (the map is saved), usually a campaign that belongs elsewhere
or model data that stops before the campaigns do. Unmapped campaigns stay listed and are not
counted; map them in a later call.
Args: model_hash: The fitted MMM the map belongs to. rows: The complete map. tolerance: The drift warning threshold as a fraction (default 0.05).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | Yes | ||
| tolerance | No | ||
| model_hash | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||