Open source · MIT

Grain

End-to-end marketing analytics: ad spend, user behaviour and the attribution between them in one workspace of panels.

v1.0.0 Ad spend and revenue in one table
Node 24TypeScriptDuckDBSVGDockerApple HIG
Grain

Where the money went and who came for it

Cloud attribution services charge by event volume and ask you to ship every customer's behaviour into someone else's database. General-purpose dashboards will draw anything, but the attribution model is assembled by hand, every time.

Grain knows about ads and about people at the same time. Spend from the ad accounts, product events and the attribution between them sit on one screen that you assemble from panels to fit your own habit. Twelve million events answer in under a tenth of a second, because underneath is a columnar DuckDB rather than a row store.

What is inside

Attribution in three models

First touch, last touch and linear, all with a 30-day window. Computed with window functions on the fly: switching the model re-runs the whole period.

A workspace of panels

Panels move, resize and are remembered. After a resize the panel is re-rendered on the server so the chart gets a real width instead of a stretched SVG.

Every number compares

Each metric carries its change against the previous period by sign, arrow and colour. For spend and CAC a rise is bad, for revenue it is good, and the screen knows the difference.

From a channel to a person

Channel to campaign to a list of people to one person's path: every ad touch and every event on a single timeline.

Charts of its own

Lines, bars, the funnel and the cohort heat map are drawn as SVG on the server, with no charting library and no front-end framework.

Twelve million rows

Embedded DuckDB: aggregates in 26–109 ms, the demo warehouse generated in five seconds directly in SQL. CSV and Parquet import is one INSERT ... SELECT.

Screenshots

The workspace: metrics, spend against revenue, channels, funnel
The workspace: metrics, spend against revenue, channels, funnel
Channels and campaigns: spend, revenue, ROAS and CAC
Channels and campaigns: spend, revenue, ROAS and CAC
Retention cohorts by week of first visit
Retention cohorts by week of first visit
People: who arrived, where from, and what they paid
People: who arrived, where from, and what they paid
The workspace in the dark theme
The workspace in the dark theme
Channels in the dark theme
Channels in the dark theme

Installation

git clone https://github.com/dripips/grain.git cd grain docker compose up -d

Have a project or idea?

Write to me and we will talk the task through.