Classifications
A classification enriches a dimension with attributes from elsewhere, without changing
anything in collection: the product line and margin of each product, the agency and budget of
each campaign, the section and author of each page. It becomes an analytics.cls_<name> view,
which eodia insights joins to the others.
| Dimension | What is classified | Join |
|---|---|---|
path | pages | key = page_views.path (or sessions.entry_path) |
utm_campaign | campaigns | key = sessions.campaign (or attribution.campaign) |
utm_source, utm_medium, utm_content, utm_term | sources, mediums, contents, terms | key = sessions.source, medium, content, term |
item_id | products | key = commerce_items.item_id |
event | event names | key = events.name |
property | the values of an event property | key = event_properties.value_text |
Each join is also made on site_id: a classification belongs to one site.
Creating a classification
Section titled “Creating a classification”In the site’s Metadata tab, Classifications section:
- a technical name, in lowercase (
catalogue): the view will be calledcls_catalogue; - a label and a description, which reach insights as comments;
- the dimension described;
- typed attributes (text, number or date), 40 at most:
gamme,marge,fournisseur.
Importing a CSV
Section titled “Importing a CSV”A CSV of 10 MB at most, separated by commas, semicolons or tabs (the separator is detected):
item_id;gamme;marge;fournisseurKA2;Audio;0.38;KerysPL-ROUGE;Maison;0.52;Tissages d’ArvorPL-BLEU;Maison;0.52;Tissages d’ArvorThe screen shows a preview of the first rows, asks for the key column and suggests a type for each column, which you correct. Then:
- Replace deletes the existing rows and loads the file;
- Merge adds the new keys and updates the existing ones.
Through the API
Section titled “Through the API”To keep a classification up to date from a catalog, with an eoa_… integration token:
curl -X PUT https://stats.example.com/api/v1/sites/$SITE_ID/classifications/$CLS_ID/rows \ -H "Authorization: Bearer $EODIA_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "mode": "merge", "rows": [ { "key": "KA2", "values": { "gamme": "Audio", "marge": 0.38, "fournisseur": "Kerys" } } ] }'POST …/classifications/:cls/import also accepts the CSV itself. The full reference is in the
API documentation, in the application (Documentation).
The cls_<name> view
Section titled “The cls_<name> view”| Column | Contents |
|---|---|
site_id | the site |
key | the classified value |
| one attribute per column | typed: text, number or date; its label as a comment |
The view’s comment states the dimension and the join to make: the insights assistant reads it.
-- Gross margin by product line, from the ordered itemsSELECT c.gamme, sum(i.revenue * c.marge) AS gross_marginFROM analytics.commerce_items iJOIN analytics.cls_catalogue c ON c.site_id = i.site_id AND c.key = i.item_idWHERE i.step = 'purchase'GROUP BY c.gammeThe view is regenerated whenever the classification changes; an import only changes its rows.
eodia analytics is free software by Eodia.