# Campaign UTM Policy Audit (`h_murdock/campaign-utm-policy-audit`) Actor

Audit campaign URLs against your UTM policy. Detect missing tags, duplicates, invalid encoding and conflicting campaign names. Export JSON, correction CSV and HTML.

- **URL**: https://apify.com/h\_murdock/campaign-utm-policy-audit.md
- **Developed by:** [Gilad Ronen](https://apify.com/h_murdock) (community)
- **Categories:** Marketing, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.25 / completed report

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### What does Campaign UTM Policy Audit do?

**Audit existing campaign links against your team's declared UTM policy** before an ad upload, newsletter send, or agency handoff. Submit JSON rows or CSV text and receive a correction queue with exact evidence, plus a complete JSON report and a downloadable HTML report.

The Actor checks supplied URLs without visiting them. It does not access analytics accounts, click ads, publish campaigns, or claim that tracking works. [Google's campaign URL guidance](https://support.google.com/analytics/answer/10917952?hl=en) explains that campaign values are case sensitive; the acceptable names, case rules, and source/medium combinations here come from your policy.

### Why use a campaign UTM policy audit?

Use the same policy each week to find missing tags, inconsistent names, duplicate parameters, and undeclared macros before links are handed off. Compare stable row and finding IDs between reports. Exact aliases make suggested field values traceable to a decision your team already made.

Apify provides API access, scheduling, storage, and integrations for recurring campaign checks. This Actor does not need a browser, proxy, third-party account, or external language model.

### How to audit campaign URLs

1. Add an array of rows with string `id` and `url` fields. Optionally add `campaignId` to compare campaign names across rows, and `channel` as a descriptive label.
2. Supply a `policy` object. An empty object requires `utm_source`, `utm_medium`, and `utm_campaign`; it adds no case restriction or value allowlist.
3. Run the Actor with a charge limit of at least USD 0.25.
4. Download the correction CSV and inspect its reasons, original values, expected policy, and explicit alias proposals. Consult the full report's policy for the complete allowlists.
5. Apply approved corrections in your campaign system and audit the next export.

### Input and policy

See the Input tab for the form and sample. Supply exactly one of `rows` or `csv`, alongside `policy`.

```json
{
  "rows": [
    {
      "id": "001",
      "campaignId": "launch-09",
      "url": "https://example.com/?utm_source=Google&utm_medium=cpc&utm_campaign=launch"
    }
  ],
  "policy": {
    "requiredParameters": ["utm_source", "utm_medium", "utm_campaign"],
    "allowedValues": { "utm_source": ["google", "newsletter"] },
    "allowedSourceMediumPairs": [{ "source": "google", "medium": "cpc" }],
    "casePolicy": "lowercase",
    "aliases": { "utm_source": { "Google": "google" } },
    "allowedMacros": ["{{campaign.name}}", "{Keyword}"]
  }
}
```

`allowedValues` uses exact decoded strings. An empty `allowedSourceMediumPairs` array disables the pair rule. `casePolicy` is `none`, `lowercase`, or `uppercase` and applies to UTM values and explicitly configured parameters. It never changes a macro provider's token case. Mixed case alone is acceptable when no case rule or restrictive allowlist is declared.

Aliases are direct, exact mappings from an old field value to its canonical value. Alias chains, self mappings, and targets contradicting an allowlist or case rule are rejected. An alias suggestion does not change the original URL, and separate source/medium proposals still need review against the pair rule. No fuzzy correction or automatic lowercasing occurs.

Supported macro token shapes are `{keyword}`, `{{campaign.name}}`, `${campaign}`, `[CAMPAIGN]`, `__CAMPAIGN_ID__`, and `%%CAMPAIGN%%`. The token body accepts ASCII letters, digits, underscore, dot, colon, and hyphen. Each exact token must be in `allowedMacros`. Approved tokens yield informational **deferred** findings because their eventual value is unknown. Unapproved or malformed templates in monitored values are reported. Regular expressions and executable template expressions are not accepted.

CSV accepts UTF-8 BOMs, quoted commas, escaped quotes, and quoted newlines. Headers must be unique and have no surrounding whitespace; inconsistent row widths are rejected. Default columns are `id,url,campaignId,channel`, with the last two optional. To use different headers, provide `columnMapping`, for example `{"id":"Link ID","url":"Destination","campaignId":"Campaign"}`. Unmapped columns are ignored. IDs are strings: `001` remains `001`. Empty/missing required IDs reject input; repeated IDs remain separate rows with findings.

Limits are 2,000 rows, 4 MB total JSON input, 12,000 characters per URL, and 100 query components per URL. Policies support 32 required parameters, 32 allowlist fields with up to 100 values each, 32 alias fields with 100 aliases each, 100 source/medium pairs, and 64 exact macros. Oversized per-URL queries become `incomplete`. An amplified report that cannot fit the safe 8 MB JSON / 9 MB per-export limits is rejected before a report event is requested; split that batch. The engine reserves 100 KB of report space for metadata while collecting evidence.

### Output and evidence

One dataset item contains the complete report and its `rows` array. The Output tab offers a row view and download links for:

- `OUTPUT`: full compact JSON, including policy, summary, query components, findings, and campaign conflict groups.
- `corrections.csv`: one line per finding, plus one line for each pass row. This is a review queue, not a rewritten URL list.
- `report.html`: escaped, standalone report with no scripts or external assets. Download the attachment to view it locally.

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel. Use the dedicated correction CSV for flat finding-level data; a generic dataset CSV contains the enclosing report rather than the same flat queue.

| Field | Meaning |
|---|---|
| `rowKey`, `issueId` | Deterministic identifiers for comparisons; duplicate input IDs receive distinct row keys |
| `originalUrl` | Exact supplied URL, including signed query bytes and fragment |
| `status` | `pass`, `review`, `invalid`, or `incomplete` |
| `deferred` | Some checks require a macro's expanded value |
| `issues` | Code, severity, parameter, original values, expected policy, optional alias proposal, evidence references |
| `campaignConflicts` | Exact literal names associated with the same supplied campaign ID |

`pass` means no findings under this policy. `review` can include a policy error, a generic URL warning, or a deferred macro check. `invalid` means unsupported URL syntax or malformed percent/UTF-8 encoding; `incomplete` means the query-component cap prevented auditing that row. Always inspect severity and reason rather than interpreting review as a tracking failure.

Query decoding treats `+` as space and `%2B` as a literal plus; `%26` stays inside its value. Fragment contents cannot satisfy required query parameters. Empty monitored values and repeated monitored keys are errors. Unconfigured empty application flags and template-like values are preserved without UTM findings. Repeated unrelated keys get a generic warning because some applications intentionally use them. No winning duplicate value is selected.

CSV cells beginning with spreadsheet formula triggers receive a protective apostrophe, including leading-whitespace cases. JSON preserves source strings. Spreadsheet applications may infer numeric display types; import identifier columns as text if you need leading zeros displayed there.

### Pricing and recovery

The price is **USD 0.25 per completed report**, using the single `report-completed` event. There is no startup charge, per-row charge, or additional dataset-item charge; platform usage is included. A completed report containing problems is still a completed report. Invalid input, insufficient budget, and report-size rejection produce no report event.

The dataset report is the primary paid result. If convenience exports fail after the dataset and charge are saved, resurrecting that same run verifies the input and saved report, then repairs the exports without a second dataset item or charge. An interrupted charge after the dataset write is completed once during recovery. Starting a new run is billable again. A charged run whose dataset was deleted cannot repair itself automatically.

### Scope, privacy, and support

This is a supplied-data policy audit, not proof of attribution, destination availability, analytics tags firing, or advertising-platform macro support. It does not infer campaign identity from `utm_id`; cross-row name grouping uses only your explicit `campaignId`, and different IDs may legitimately share a name. Malformed or unresolved templates are not treated as literal campaign-name evidence.

Outputs retain the URLs and query values you submit, so use data you are authorized to process and avoid supplying live secrets. No URLs are fetched, and no customer links or values are written to application logs. Use the Actor's Issues tab for reproducible problems and the API tab for integration instructions.

# Actor input Schema

## `rows` (type: `array`):

Array of {id,url,campaignId?,channel?}. Duplicate IDs are reported, never merged. Use either rows or csv.

## `csv` (type: `string`):

Alternative to rows: UTF-8 CSV with id,url and optional campaignId,channel. Supports BOM and quoted fields. Do not supply rows at the same time.

## `columnMapping` (type: `object`):

Optional field-to-header map for CSV, for example {"id":"Link ID","url":"Destination"}. id/url default to their own names. Unmapped extra CSV columns are ignored.

## `policy` (type: `object`):

Required parameters, exact allowedValues, source/medium pairs, optional lowercase/uppercase value policy, direct aliases and exact allowedMacros. See README for supported syntax and limits.

## Actor input object example

```json
{
  "rows": [
    {
      "id": "001",
      "campaignId": "C001",
      "channel": "search",
      "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=autumn"
    },
    {
      "id": "002",
      "campaignId": "C001",
      "channel": "search",
      "url": "https://shop.example.test/?utm_source=Google&utm_medium=cpc&utm_campaign=autumn"
    },
    {
      "id": "003",
      "channel": "search",
      "url": "https://shop.example.test/?utm_source=google&utm_source=bing&utm_medium=cpc&utm_campaign=autumn"
    },
    {
      "id": "004",
      "campaignId": "C002",
      "channel": "email",
      "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=spring"
    },
    {
      "id": "005",
      "campaignId": "C002",
      "channel": "email",
      "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=Spring"
    },
    {
      "id": "006",
      "campaignId": "C003",
      "channel": "ads",
      "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign={{campaign.name}}&utm_term={Keyword}"
    },
    {
      "id": "007",
      "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=bad%GG"
    },
    {
      "id": "008",
      "url": "https://shop.example.test/?utm_source=newsletter#utm_medium=email&utm_campaign=summer"
    },
    {
      "id": "009",
      "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=summer&utm_content=a%26b&utm_term=a+b&sig=A%2bb%2F%3d&flag=#keep"
    },
    {
      "id": "=HYPERLINK(\"https://example.test\")",
      "channel": "=1+1",
      "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=&utm_content={unknown}"
    }
  ],
  "policy": {
    "requiredParameters": [
      "utm_source",
      "utm_medium",
      "utm_campaign"
    ],
    "allowedValues": {
      "utm_source": [
        "google",
        "newsletter"
      ],
      "utm_medium": [
        "cpc",
        "email"
      ]
    },
    "allowedSourceMediumPairs": [
      {
        "source": "google",
        "medium": "cpc"
      },
      {
        "source": "newsletter",
        "medium": "email"
      }
    ],
    "casePolicy": "lowercase",
    "aliases": {
      "utm_source": {
        "Google": "google"
      }
    },
    "allowedMacros": [
      "{{campaign.name}}",
      "{Keyword}"
    ]
  }
}
```

# Actor output Schema

## `report` (type: `string`):

No description

## `corrections` (type: `string`):

No description

## `html` (type: `string`):

No description

## `dataset` (type: `string`):

No description

## `rows` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "rows": [
        {
            "id": "001",
            "campaignId": "C001",
            "channel": "search",
            "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=autumn"
        },
        {
            "id": "002",
            "campaignId": "C001",
            "channel": "search",
            "url": "https://shop.example.test/?utm_source=Google&utm_medium=cpc&utm_campaign=autumn"
        },
        {
            "id": "003",
            "channel": "search",
            "url": "https://shop.example.test/?utm_source=google&utm_source=bing&utm_medium=cpc&utm_campaign=autumn"
        },
        {
            "id": "004",
            "campaignId": "C002",
            "channel": "email",
            "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=spring"
        },
        {
            "id": "005",
            "campaignId": "C002",
            "channel": "email",
            "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=Spring"
        },
        {
            "id": "006",
            "campaignId": "C003",
            "channel": "ads",
            "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign={{campaign.name}}&utm_term={Keyword}"
        },
        {
            "id": "007",
            "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=bad%GG"
        },
        {
            "id": "008",
            "url": "https://shop.example.test/?utm_source=newsletter#utm_medium=email&utm_campaign=summer"
        },
        {
            "id": "009",
            "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=summer&utm_content=a%26b&utm_term=a+b&sig=A%2bb%2F%3d&flag=#keep"
        },
        {
            "id": "=HYPERLINK(\"https://example.test\")",
            "channel": "=1+1",
            "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=&utm_content={unknown}"
        }
    ],
    "policy": {
        "requiredParameters": [
            "utm_source",
            "utm_medium",
            "utm_campaign"
        ],
        "allowedValues": {
            "utm_source": [
                "google",
                "newsletter"
            ],
            "utm_medium": [
                "cpc",
                "email"
            ]
        },
        "allowedSourceMediumPairs": [
            {
                "source": "google",
                "medium": "cpc"
            },
            {
                "source": "newsletter",
                "medium": "email"
            }
        ],
        "casePolicy": "lowercase",
        "aliases": {
            "utm_source": {
                "Google": "google"
            }
        },
        "allowedMacros": [
            "{{campaign.name}}",
            "{Keyword}"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("h_murdock/campaign-utm-policy-audit").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "rows": [
        {
            "id": "001",
            "campaignId": "C001",
            "channel": "search",
            "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=autumn",
        },
        {
            "id": "002",
            "campaignId": "C001",
            "channel": "search",
            "url": "https://shop.example.test/?utm_source=Google&utm_medium=cpc&utm_campaign=autumn",
        },
        {
            "id": "003",
            "channel": "search",
            "url": "https://shop.example.test/?utm_source=google&utm_source=bing&utm_medium=cpc&utm_campaign=autumn",
        },
        {
            "id": "004",
            "campaignId": "C002",
            "channel": "email",
            "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=spring",
        },
        {
            "id": "005",
            "campaignId": "C002",
            "channel": "email",
            "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=Spring",
        },
        {
            "id": "006",
            "campaignId": "C003",
            "channel": "ads",
            "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign={{campaign.name}}&utm_term={Keyword}",
        },
        {
            "id": "007",
            "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=bad%GG",
        },
        {
            "id": "008",
            "url": "https://shop.example.test/?utm_source=newsletter#utm_medium=email&utm_campaign=summer",
        },
        {
            "id": "009",
            "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=summer&utm_content=a%26b&utm_term=a+b&sig=A%2bb%2F%3d&flag=#keep",
        },
        {
            "id": "=HYPERLINK(\"https://example.test\")",
            "channel": "=1+1",
            "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=&utm_content={unknown}",
        },
    ],
    "policy": {
        "requiredParameters": [
            "utm_source",
            "utm_medium",
            "utm_campaign",
        ],
        "allowedValues": {
            "utm_source": [
                "google",
                "newsletter",
            ],
            "utm_medium": [
                "cpc",
                "email",
            ],
        },
        "allowedSourceMediumPairs": [
            {
                "source": "google",
                "medium": "cpc",
            },
            {
                "source": "newsletter",
                "medium": "email",
            },
        ],
        "casePolicy": "lowercase",
        "aliases": { "utm_source": { "Google": "google" } },
        "allowedMacros": [
            "{{campaign.name}}",
            "{Keyword}",
        ],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("h_murdock/campaign-utm-policy-audit").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "rows": [
    {
      "id": "001",
      "campaignId": "C001",
      "channel": "search",
      "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=autumn"
    },
    {
      "id": "002",
      "campaignId": "C001",
      "channel": "search",
      "url": "https://shop.example.test/?utm_source=Google&utm_medium=cpc&utm_campaign=autumn"
    },
    {
      "id": "003",
      "channel": "search",
      "url": "https://shop.example.test/?utm_source=google&utm_source=bing&utm_medium=cpc&utm_campaign=autumn"
    },
    {
      "id": "004",
      "campaignId": "C002",
      "channel": "email",
      "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=spring"
    },
    {
      "id": "005",
      "campaignId": "C002",
      "channel": "email",
      "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=Spring"
    },
    {
      "id": "006",
      "campaignId": "C003",
      "channel": "ads",
      "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign={{campaign.name}}&utm_term={Keyword}"
    },
    {
      "id": "007",
      "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=bad%GG"
    },
    {
      "id": "008",
      "url": "https://shop.example.test/?utm_source=newsletter#utm_medium=email&utm_campaign=summer"
    },
    {
      "id": "009",
      "url": "https://shop.example.test/?utm_source=google&utm_medium=cpc&utm_campaign=summer&utm_content=a%26b&utm_term=a+b&sig=A%2bb%2F%3d&flag=#keep"
    },
    {
      "id": "=HYPERLINK(\\"https://example.test\\")",
      "channel": "=1+1",
      "url": "https://shop.example.test/?utm_source=newsletter&utm_medium=email&utm_campaign=&utm_content={unknown}"
    }
  ],
  "policy": {
    "requiredParameters": [
      "utm_source",
      "utm_medium",
      "utm_campaign"
    ],
    "allowedValues": {
      "utm_source": [
        "google",
        "newsletter"
      ],
      "utm_medium": [
        "cpc",
        "email"
      ]
    },
    "allowedSourceMediumPairs": [
      {
        "source": "google",
        "medium": "cpc"
      },
      {
        "source": "newsletter",
        "medium": "email"
      }
    ],
    "casePolicy": "lowercase",
    "aliases": {
      "utm_source": {
        "Google": "google"
      }
    },
    "allowedMacros": [
      "{{campaign.name}}",
      "{Keyword}"
    ]
  }
}' |
apify call h_murdock/campaign-utm-policy-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,h_murdock/campaign-utm-policy-audit"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/di1GwDXOPDUDp94x6/builds/HPSPx0MgtJCexSOqG/openapi.json
