# Analytics

**Analiză** shows how the shop sells and, for staff with *finance* rights, what it earns. It needs *Sees the sales
reports* (Shop manager, Marketing and Accountant have it by default); costs, margins and profit also need *Sees
costs, margins and profit* (Shop manager and Accountant).

The tabs at the top move between the reports: **Panou**, **Clienți**, **Abonamente** and **Pe e-mail** for everyone with
analytics rights, **Profit
pe luni**, **Marje**, **Creanțe B2B**, **Stoc**, **Verificare TVA** and **Costuri lunare** only with finance
rights.

## Choosing the period

Every report has the same period picker: the last 7 or 30 days, this or last month, this quarter or year, or two dates
of your own (choose **Alte zile**). Figures are compared with the period just before and with the same days a year
earlier, with an arrow, a sign and the words; never with colour alone.

## Sales

Orders placed, sales (with VAT and delivery, without cancelled orders), the average order value and the products
sold, with a chart of sales by day (and the same figures as a table under **Vezi ca tabel**). Orders in another
currency are converted at the BNR rate of their day; an order whose rate is missing is counted apart. Orders brought
over from your previous shop count too, so the comparison with last year works from the first day.

## Customers

A customer is an e-mail address: guest orders and account orders by the same address are one customer; cancelled
orders do not count.

- **Clienți noi** (their first order fell in the period) and **clienți care revin** (they had ordered before), against
  the period before.
- **Rata de revenire**: the share of all customers so far who ordered at least twice. **Valoare medie pe client**:
  what a customer bought in all, on average, with VAT.
- **Costul unui client nou** (finance rights): the period's marketing spend divided by its new customers; it needs
  the month's marketing in **Costuri lunare**.
- **Segmente**: every customer in one group by how recently and how often they bought: Campioni (3+ orders, the last
  within 90 days), Fideli (2+, within 180 days), Noi (one order, within 30 days), Promițători (one order, 31–90 days
  ago), În pericol (2+ orders, the last 6–12 months ago), Adormiți (one order, 3–12 months ago) and Pierduți (nothing
  for over a year). Plain rules rather than scores, so you can tell anyone why a customer is where they are.
- **Cohorte**: customers by the month of their first order, and what share of them ordered again 1, 2… 11 months
  later. The shade repeats the number; a dot means that month has not come yet.

## Profit

From the profit ledger, for orders fulfilled in the period, in lei without VAT: net revenue, gross margin, contribution
margin (after delivery and payment fees) and the orders fulfilled. When some costs are missing (a product without a
cost, a shipment or a payment whose cost the courier or processor did not report and that has no rate card), the page
says how many: the margins are then too high, never quietly so.

- **Profit pe luni**: the management P&L month by month, from sales down to operating profit, over 6, 12 or 24
  months, with the missing costs counted in each month. Marketing and fixed costs show *neintrodus* for a month you
  have not entered, rather than a zero.
- **Marje**: net revenue, cost of goods and gross margin by product, brand or main category, the biggest first; a row
  with lines of unknown cost says how many.

Both export to CSV for Excel (semicolons, UTF-8; cells that a spreadsheet would read as formulas are neutralised).

## Subscriptions

**Abonamente** shows the revenue that renews: the monthly recurring revenue now (a yearly plan's price over 12, a
weekly one's × 52 / 12, in lei with VAT), against a month and a year ago, and what it makes in a year; the active
subscriptions (and how many await a payment); the average per subscription; and the renewals whose payment failed in
the last 90 days that were paid in the end. Month by month: the revenue at the month's end, the subscriptions started
and stopped with their revenue, and the churn rate against those active when the month began (by count and by
revenue). Paused subscriptions count as stopped; a pause that has already ended leaves no trace in the months it
covered.

## AI traffic

**Trafic AI** (AI traffic) shows, for the period you choose, who comes to the shop from an AI assistant's answer and
what the assistants' crawlers read. Anyone who sees analytics sees it; it holds no costs.

- **Per assistant** (ChatGPT, Perplexity, Claude, Gemini, Microsoft Copilot, Grok, DeepSeek, Le Chat, Meta AI): the
  visits, the orders from those visits, their sales in lei with VAT, and the conversion (orders per visit). A visit is
  counted once, on the page the person landed on, when the link came from the assistant's site or carries its
  `utm_source` (ChatGPT adds `utm_source=chatgpt.com` to its links). Many apps do not tell the shop where a visitor
  comes from, so read the visits as a minimum.
- **Unde ajung vizitatorii** (where visitors land): the ten pages most visits from assistants arrive on.
- **Roboții AI** (AI crawlers): each crawler from Settings → SEO și roboți AI that fetched pages, whether it reads for
  answers or collects for training, its hits, the distinct pages and the last day seen; and **Ce citesc roboții AI**,
  the ten pages they fetched most. Crawlers are recognised by the name in their user agent, which is not verified.

Nothing about visitors is kept: only counts per day, page and assistant or crawler, so no cookie consent is needed for
them. An order is linked to the assistant only when the visitor allowed **statistics** cookies, so the order counts
are a minimum too. Agent orders placed through the [MCP server](storefront.md) are a separate thing: their basket was
made by the assistant itself.

## B2B receivables

**Creanțe B2B** shows what companies owe today for orders bought on terms (finance rights): the total to collect, how
much is overdue, the days it takes to collect (what is owed, in days of the last 90 days' sales on terms) and how many
companies are over their credit limit. The aging table splits it into not yet due, 1–30, 31–60, 61–90 and over 90 days
overdue; the company table shows each one's balance, overdue part, oldest late order and use of its credit limit
("peste limită" is written out, not only coloured). An order leaves the list once it is marked as collected; cancelled
and returned orders never count. Export it to CSV.

## Stock

**Stoc** (finance rights) values the goods in every location at their cost (the weighted average from goods receipts,
otherwise the manual cost), without VAT: the total and the units, the days the stock would last at the last year's
cost of goods sold, and what has not sold for 90 or 180 days (choose above the list). A product without a cost is
counted and marked *fără cost*, never valued at zero. The unsold list shows the 200 biggest by value; the CSV has them
all.

## VAT check

**Verificare TVA** (finance rights) compares, for a month (the previous one by default; move with the arrows), the VAT
by rate on the invoices issued (credit notes taken off, other currencies at the BNR rate of the invoice's day) with
the VAT on the orders fulfilled in that month. It lists the fulfilled orders that have no invoice and the invoices
whose total differs from their order's. A difference by rate is natural when an order is fulfilled in one month and
invoiced in the next. It is a check for you, not a return: the VAT return stays with your accountant. In-store sales
on a fiscal receipt and the imported history are left out.

## Monthly costs

**Costuri lunare** (finance rights) takes each month's fixed costs (rent, salaries and contributions, software and
hosting, accounting, utilities, other) and marketing spend by channel (Google Ads, Meta, TikTok, e-mail and SMS,
content and partnerships, other), in lei without VAT. Move between months with the arrows; **Copiază din luna
trecută** fills the form from the month before, to check and save. Under the form, the last twelve months' totals.

Marketing counts in the contribution margin, fixed costs come after it: **operating profit = contribution − fixed
costs**. On the dashboard a month's amounts are spread evenly over its days, so a week carries a week's share.
Changing an amount books the difference; nothing already booked is rewritten. Approved affiliate commissions also count as marketing, on the day they were approved (see
[Affiliates](affiliates.md#commissions)); they need no entry here.

The figures are rebuilt every hour for today and yesterday, and every night for the last five weeks, so a cost that
arrives late (a courier's invoice) is counted on its order's day. For outside BI tools (Metabase, Power BI), the Integration API has the profit ledger (`/api/v1/ledger-entries`)
and the monthly costs (`/api/v1/period-costs`), read-only, for keys whose holder has finance rights (see
[API keys](api.md)).

## Reports by e-mail

**Pe e-mail** (everyone with analytics rights) lets each person choose which reports they get, weekly (Monday morning,
for the week before) or monthly (on the 1st, for the month before), at the e-mail address of their admin account:
**Pe scurt** (orders, sales and average order value against the period before; with finance rights also net revenue,
margins and any missing costs), and with finance rights **Profit pe luni**, **Marje pe produse**, **Creanțe B2B** and
**Stoc nevândut**, attached as CSV. Only the reports you may see are offered, and a report goes out only while you may
still see it.

## Ask (the copilot)

**Analiză → Întreabă** (ask) answers questions in plain words, such as „care branduri au pierdut marjă în trimestrul
ăsta?” (which brands lost margin this quarter?). It needs **Copilot pentru analiză** (analytics copilot) switched on
under Settings → AI.

- An AI picks one of the shop's reports and its settings:
  - **sales**: orders, items, sales with VAT, average order;
  - **margins**: by product, brand or category, compared with an earlier period, ordered by the biggest drop, the
    biggest gain or revenue;
  - **profit and loss**: net revenue, cost of goods, gross margin, marketing, contribution, operating profit.

  It also picks the period and what to compare it with. It never writes a database query.
- The shop runs that report. The AI then answers **only from its figures**, and the same figures are shown under the
  answer as a table, with a link to the full report.
- Staff without **costs and margins** (`analytics.finance`) are offered the sales report only. A question that needs
  costs gets "your account cannot see them".
- The question and the answer stay in your session. The AI log keeps only which model was used, the tokens, the cost
  and the time. E-mail addresses and long digit runs are taken out of the question before it is sent.

