Quick Overview
This workflow ingests marketing touch events, stores them in Supabase, stitches identities by shared email, and calculates first-touch, last-touch, linear, and time-decay multi-touch attribution credit per channel, outputting a side-by-side model comparison.
How it works
- Runs when triggered manually (or can be adapted to receive real touch events via a webhook).
- Loads configuration such as the channel list and the time-decay half-life window.
- Generates a batch of synthetic multi-touch customer journeys for the demo run.
- Writes all touch events to a Supabase table via the Supabase REST API.
- Reloads the stored touches from Supabase and merges visitors into a single identity when they share an email address.
- Computes revenue-weighted channel credit across converting journeys using first-touch, last-touch, linear, and time-decay attribution models.
- Prints a formatted comparison table of channel credit across the four models.
Setup
- Create a Supabase project and table (for example,
mta_touches) to store touch events, matching the fields used in the workflow (visitor_id, email, channel, ts, is_conversion, revenue).
- Add
SUPABASE_URL and SUPABASE_KEY environment variables to your n8n instance so the workflow can call the Supabase REST API.
- Update the Supabase table name and any row-filtering logic in the Supabase requests if your schema or naming differs.
- If you want production ingestion, replace the synthetic journey generator with a Webhook trigger that posts real touch events into the same storage step.
- Adjust
HALF_LIFE_DAYS and CHANNELS in the configuration to match your attribution model settings and marketing taxonomy.