Multi-touch Attribution QA Runbook

In the docs

This runbook covers release QA, on-call checks and maintenance for multi-touch attribution in Prosper202 1.9.76 and later. Each check includes the p202 command that runs it. Checks that require SQL or a PHP script are marked below. Commands that read need an API key with the attribution:read scope; model changes also need attribution:write. From 1.9.80, the p202 CLI needs only an active free ClickServer licence on the install (1.9.78 and 1.9.79 need Prosper202 ClickServer Pro or its 7-day trial); without one, most commands stop with exit code 6. The attribution reads and model changes are also in the REST API under /api/v3/attribution, which is available on every installation.

How the engine works

  1. Every conversion write, from a pixel, postback, upload or the API, records a ledger row and queues the conversion in the outbox, 202_attribution_pending.
  2. The attribution worker processes queued conversions from the outbox. The minutely cron (202-cronjobs/index.php) runs it for 20 seconds each minute. 202-cronjobs/attribution-worker.php runs the same worker on its own, 50 seconds by default. A MySQL named lock keeps two workers from overlapping.
  3. For each conversion, the worker builds one journey: up to 25 clicks by the same visitor, inside the widest lookback of your active models (never less than 30 days). Clicks are linked through visitor keys, never by IP address or user agent. The journey is written to 202_attribution_journeys, and its construction details are saved in 202_attribution_journey_meta.
  4. The worker calculates credit for each active model and saves it in 202_attribution_credits. Under each model, a conversion's credits add up to exactly 1, and its credited revenue adds up to exactly its counted amount.
  5. Each write marks the report hours it touched. The worker recalculates those hours in 202_attribution_rollup, which reports and exports read.

Changing a model's type, weighting or lookback re-queues every conversion in the account. When two visitors are found to be one person, that person's conversions are re-queued too.

Upgrading from 1.9.55 or earlier: the worker brings existing conversions into multi-touch attribution on its own, at roughly 20 minutes of worker time per million conversions. backfill in p202 attribution queue shows its progress. The upgrade is one-way, so back up the database first; see Upgrading.

The hourly engine is gone. Development builds between 1.9.55 and 1.9.76 had an earlier, hourly attribution engine. No release included it: 1.9.55 was the last release before 1.9.76, and 1.9.76 removed it. If you ran one of those builds, 1.9.76 no longer uses any of these:

  • The tables 202_conversion_touchpoints, 202_attribution_settings, 202_attribution_snapshots and 202_attribution_touchpoints.
  • The /api/v2/attribution endpoints. Use /api/v3/attribution instead; see the API guide.
  • The scripts attribution-rebuild.php and backfill-conversion-journeys.php. Delete any crontab lines that call them.
  • The Dashboard System Checks page.

1. Health check

Run this after every deploy or upgrade, and at the start of an on-call investigation.

  1. Check cron timing. p202 system cron shows the last run for each job type. The every-minute row should be under two minutes old. 202-cronjobs/health.php treats over 2 minutes as a warning and over 10 as critical.
  2. Check the queue. Run p202 attribution queue. A healthy install looks like this:
    backfill:
    failing:                    0
    merges_awaiting_requeue:    0
    models_awaiting_recompute:  0
    oldest_enqueued_at:
    pending:                    0
    rows:                       []
    pending rises with traffic and should fall back within a minute or two. If it keeps growing, the worker isn't running. models_awaiting_recompute is above 0 only right after a model change. backfill stays empty once the post-upgrade backfill has finished.
  3. Check failures. When failing is above 0, rows lists each conversion with its attempts and last_error. Failed rows retry on their own, waiting longer each time, from one minute up to a day. To retry them now, fix what last_error names and run php 202-cronjobs/attribution-worker.php --retry-now. A database error stops the run without using a retry attempt for any queued row.
  4. Check model status. In p202 attribution model list, each model should be active or inactive. invalid means its stored definition failed validation. p202 attribution model get <id> shows why in status_reason. The other models keep computing in the meantime.

2. Models and configuration

  1. One default per account, always active. A unique key in the database enforces this (one_default on 202_attribution_models). The default can't be unset, deactivated or deleted. To replace it, make another model the default first.
  2. Types and weighting. The weighting config is a JSON object:
    TypeWeighting config
    last_touch, first_touch, linearnone
    time_decay{"half_life_hours":48}, up to 8760
    position_based{"first_weight":0.4,"last_weight":0.4}, each 0–1, together at most 1
    Lookback isn't part of the weighting config. It's a model setting, --lookback-days, from 1 to 365 days, default 30. Changing a model's type resets its weighting to that type's defaults.
  3. Create a QA model: p202 attribution model create --model-name "QA linear" --model-type linear. The next worker run computes its credits for existing conversions. Watch models_awaiting_recompute go to 1, then back to 0.
  4. Change a model: p202 attribution model update <id> --weighting-config '{"half_life_hours":24}'. The response sets recompute_pending, and the queue shows the recompute until it finishes.
  5. Per-campaign model: p202 campaign update <id> --attribution-model-id <model_id> credits that campaign's conversions with a model other than the default. 0 returns the campaign to the default.
  6. Audit trail: every model create, update and delete, and every export, writes a row to 202_attribution_audit. The actions are model_created, model_updated (with the fields changed and whether it recomputed), model_deleted and export_created. Neither the CLI nor the API reads these rows; this is SQL only:
    SELECT FROM_UNIXTIME(created_at) AS at, action, model_id, metadata
    FROM 202_attribution_audit
    WHERE user_id = 1
    ORDER BY audit_id DESC
    LIMIT 20;

3. Journey validation

  1. Check one conversion end to end. p202 attribution journey <conv_id> shows three things. touches lists each click in order, with the signals that linked it. journey records how the journey was built. credits gives every model's split. From a two-touch conversion worth 208.00:
    "journey": {"built_lookback_days": 30, "identified": true, "touches": 2, "truncated": false},
    "credits": [
      {"model_name": "Last touch",  "touches": [{"position": 1, "credit": "1.00000000", "revenue": "208.00000"}]},
      {"model_name": "First touch", "touches": [{"position": 0, "credit": "1.00000000", "revenue": "208.00000"}]},
      {"model_name": "Position based (40/20/40)", "touches": [
        {"position": 0, "credit": "0.50000000", "revenue": "104.00000"},
        {"position": 1, "credit": "0.50000000", "revenue": "104.00000"}]}
    ]
    Expect positions to start at 0 and run without gaps, with the converting click last and present exactly once. Under each model, credits add up to 1 and revenue to amount. A conversion with counted: false has no credits; it was superseded, deleted or fully reversed. p202 click conversions <click-id> explains why a conversion counts or doesn't.
  2. Check the population. p202 attribution journeys --period last7 gives the journey-length distribution, time to convert, and the one-touch share by browser. If nearly every journey is one touch, clicks aren't being joined. Check:
    • The campaign's --identity-signals setting (1 links its clicks into journeys).
    • That landing pages load the tracking script.
    • That clicks go through your tracking domain.
    Some browsers clear redirect-domain cookies. Compare the one-touch share by browser to see the effect on journey matching.
  3. Long journeys. A journey over 25 touches keeps the newest 25, including the converting click, and records truncated: 1 in its journey meta.
  4. Database invariants (read-only SQL). Both queries should return no rows:
    -- every stored journey has positions 0..touches-1
    SELECT m.conv_id
    FROM 202_attribution_journey_meta m
    JOIN 202_attribution_journeys j ON j.conv_id = m.conv_id
    GROUP BY m.conv_id, m.touches
    HAVING COUNT(*) <> m.touches OR MAX(j.position) <> m.touches - 1;
    
    -- under every model, a conversion's credits add up to exactly 1
    SELECT conv_id, model_id, SUM(credit) AS total
    FROM 202_attribution_credits
    GROUP BY conv_id, model_id
    HAVING total <> 1;

4. Reports and exports

  1. Totals reconcile. p202 attribution breakdown --group-by campaign --period last30 credits each campaign with its own model, or the default if it has none. --model <id> picks one model, and --compare-model <id> adds a second model's columns side by side. Every model credits the same total revenue; they differ only in which clicks receive it. --cohort click counts what the range's clicks earned, as the classic reports do.
  2. 409 from a report means the model it asked for is inactive or invalid. Report on an active model, or fix that one.
  3. Exports. p202 attribution export create queues a breakdown to CSV, optionally sent to a signed https webhook. The minutely cron runs due exports. For details and recovery: A webhook must resolve to a public address. A receiver on your own network needs its range listed in P202_WEBHOOK_ALLOW_NETWORKS in 202-config.php, written in CIDR form.

5. Recompute and repair

  1. Don't delete journey or credit rows by hand. Nothing re-queues a conversion whose rows are gone. A raw DELETE also skips the report-hour marks every engine write leaves, so reports for those hours go stale.
  2. Recompute a model by changing it, with p202 attribution model update. Any change to its type, weighting or lookback re-queues every conversion in the account.
  3. Watch the worker by running it in a terminal: php 202-cronjobs/attribution-worker.php --budget=300. It accepts --budget=N (1–3600 seconds) and --retry-now. It prints one line per run, which is also written to the cron log:
    attribution-worker: processed 42 (cleared=2, credited=40); merges re-queued 1; model changes fanned out 0; still due 0

6. Incident response and rollback

  1. A model is assigning incorrect credit.
    • If it's the default, move the default to a safe model first: p202 attribution model update <safe_id> --default.
    • Then deactivate the affected model: p202 attribution model update <bad_id> --status inactive. The other models keep computing.
    • To remove it entirely, run p202 attribution model delete <id> --dry-run first. Delete removes the model's credits and exports, and is refused while one of its exports is running.
    The equivalent REST API request is PUT /api/v3/attribution/models/{id} with {"status": "inactive"}. The API returns 422 for unknown fields, including the old is_active.
  2. Reports have stopped updating. Work through the health check. A growing pending with a stale every-minute cron row means the cron isn't running. Run the worker by hand to see its error.
  3. An upgrade went wrong. The upgrade changes the database in place, so restoring the backup taken before it is the only way back. Replacing the files with an older version does not undo the database upgrade.
  4. Escalate with these attached:
    • The output of p202 attribution queue --json and p202 attribution model list --json.
    • The worker's cron log lines.
    • The latest 202_attribution_audit rows.
    • p202 system info.
    Send them to the team through the chat inside Prosper202.

Written for Prosper202 1.9.76 and checked against 1.9.78. Check this runbook against the schema, cron and commands whenever the attribution engine changes.