/api/channel_attribution

Header
POST https://api.Fluxrails.app/api/v1/ai/channel_attribution
X-Customer-Api-Id: <uuid>
X-Secret: <secret>
Content-Type: application/json
Request Body Schema
// Request Body Schema
{
  "min_events": integer,          // optional, defaults to 200
  "touches": [
    {
      "user_id": string,         // consistent identifier
      "channel": string,         // case-sensitive label
      "timestamp": string,       // ISO-8601 UTC
      "converted": 0|1,          // 1 if user ultimately converted
      "features": {              // optional per-event/user attributes
        "<feature_name>": number|string,
        …
      }
    },
    …
  ]
}
Example Request Body
// Example Request (replace stub with ≥200 real rows)
{
  "min_events": 200,
  "touches": [
    {
      "user_id": "U-000",
      "channel": "display",
      "timestamp": "2025-04-01T09:00:00Z",
      "converted": 0,
      "features": { "device": "desktop", "country": "CA" }
    },
    {
      "user_id": "U-001",
      "channel": "email",
      "timestamp": "2025-04-01T11:30:00Z",
      "converted": 0,
      "features": { "device": "mobile", "country": "UK" }
    },
    {
      "user_id": "U-002",
      "channel": "paid_search",
      "timestamp": "2025-04-01T12:30:00Z",
      "converted": 1,
      "features": { "device": "desktop", "country": "US" }
    }
    // … add ≥197 more touches …
  ]
}
Example Response Body
// Example Response
{
  "contributions": [
    {
      "channel": "paid_search",
      "n_events": 53,
      "raw_cr": 0.283,
      "incremental_lift": 0.632,
      "description": "↗ strong driver"
    },
    {
      "channel": "social",
      "n_events": 51,
      "raw_cr": 0.1569,
      "incremental_lift": -0.0257,
      "description": "neutral / needs test"
    },
    {
      "channel": "email",
      "n_events": 39,
      "raw_cr": 0.1282,
      "incremental_lift": -0.1928,
      "description": "↘ drag on conversions"
    },
    {
      "channel": "display",
      "n_events": 57,
      "raw_cr": 0.1053,
      "incremental_lift": -0.4127,
      "description": "↘ drag on conversions"
    }
  ],
  "global_auc": 0.6589,
  "interpretation": "Elastic-net logistic regression (AUC=0.659) indicates **paid_search** drives the highest incremental lift (++0.632) across 53 touches (raw CR 28.30%), while **display** under-performs (-0.413)."
}
Description

• Computes causal or pseudo-causal incremental lift (ATE) per marketing channel. • Distinguishes true drivers from last-click bias by controlling for confounders. • Falls back to elastic-net logistic regression if doubleml isn’t installed.

Business Usage

• Allocate budget to channels with positive lift (“↗ strong driver”). • Identify under-performers (“↘ drag on conversions”) for creative or strategy tweaks. • Track AUC to ensure model robustness and guard-rail against under-sampling (< min_events). • Integrate into your weekly marketing performance dashboard for data-driven re-budgeting.

← Back to all routes