Skip to content

Tag Groups

Tag groups are named groupings of product tags linked by membership. Staff save these groups for repeated analytics queries. Instead of manually selecting the same set of tags each time, users create a tag group (e.g., “Summer 2024 Collection”) and track its metrics over time via tag analytics.

Goal: Enable reusable, named tag groups for consistent performance tracking.

Tag group CRUD (internal, not yet specced)

Section titled “Tag group CRUD (internal, not yet specced)”
MethodPathDescription
GET/api/tag-groupsList all tag groups
POST/api/tag-groupsCreate or update a tag group (upsert by name)
DELETE/api/tag-groups/:groupIdDelete a tag group
MethodPathSpecDescription
GET/tagsproduct.yamlList available tags for group membership
GET/categoriesproduct.yamlList categories (tag groups rewrite uses product_category table)
GET/api/tag-analytics/group-performance/:groupId(not yet specced)Metrics for a saved tag group
TableModuleRole
product_categoryProductCRUD: tag group storage (rewrite target for Drizzle)
product_tagProductRead: available tags for group membership
ResourceTypePurpose
dashboard-apiCF Worker (internal)CRUD endpoints for tag groups
PlanetScale (Hyperdrive)Managed PostgresTag group + tag data storage
ActorRole
Staff user (Creative/Ops)Creates, edits, and deletes tag groups
Dashboard API WorkerServes CRUD endpoints
PlanetScaleStore for tag groups
// POST /api/tag-groups
{
name: string, // Tag group name, e.g. "Summer 2024 Collection"
tagNames: string[] // Tag identifiers, e.g. ["summer-2024", "floral", "tropical"]
}

The endpoint upserts — if a tag group with the same name already exists, it updates the member tags.

interface TagGroup {
id: string; // UUID
name: string; // Group name
tagNames: string[]; // Member tag identifiers
}
ColumnTypeDescription
idUUIDPrimary key
nameVARCHAR(255)Tag group name
tag_namesJSONBArray of tag identifiers (membership relation)
temporal_originTIMESTAMPTZCreation timestamp
last_modified_atTIMESTAMPTZLast update timestamp

Tag groups feed into the tag analytics group performance endpoint:

GET /api/tag-analytics/group-performance/:groupId

This looks up the tag group’s member tags and runs the same aggregate metric query as the bulk performance endpoint.

The current system uses Supabase RPCs (upsert_tag_group, get_tag_groups, delete_tag_group). In the rewrite, these become straightforward Drizzle CRUD operations on the product_category table.

  • Creating a tag group with a new name inserts a new record
  • Creating a tag group with an existing name updates the member tags
  • Deleting a tag group removes it and its analytics no longer resolve
  • Tag group performance via analytics endpoint returns correct aggregated metrics