Skip to content

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.

DimensionWhat is classifiedJoin
pathpageskey = page_views.path (or sessions.entry_path)
utm_campaigncampaignskey = sessions.campaign (or attribution.campaign)
utm_source, utm_medium, utm_content, utm_termsources, mediums, contents, termskey = sessions.source, medium, content, term
item_idproductskey = commerce_items.item_id
eventevent nameskey = events.name
propertythe values of an event propertykey = event_properties.value_text

Each join is also made on site_id: a classification belongs to one site.

In the site’s Metadata tab, Classifications section:

  • a technical name, in lowercase (catalogue): the view will be called cls_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.

A CSV of 10 MB at most, separated by commas, semicolons or tabs (the separator is detected):

item_id;gamme;marge;fournisseur
KA2;Audio;0.38;Kerys
PL-ROUGE;Maison;0.52;Tissages d’Arvor
PL-BLEU;Maison;0.52;Tissages d’Arvor

The 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.

To keep a classification up to date from a catalog, with an eoa_… integration token:

Fenêtre de terminal
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).

ColumnContents
site_idthe site
keythe classified value
one attribute per columntyped: 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 items
SELECT c.gamme, sum(i.revenue * c.marge) AS gross_margin
FROM analytics.commerce_items i
JOIN analytics.cls_catalogue c ON c.site_id = i.site_id AND c.key = i.item_id
WHERE i.step = 'purchase'
GROUP BY c.gamme

The view is regenerated whenever the classification changes; an import only changes its rows.

eodia analytics is free software by Eodia.