Semantic Model API: Sample Flows

This article presents possible use cases and corresponding sample flows. It provides a useful starting point for planning an implementation.

Display site performance data on a dashboard

This flow shows analytics data (such as sessions and revenue) on a custom dashboard. It discovers which semantic models are available, inspects the semantic model schema to find the right fields, and then retrieves the data.

Before the flow runs, the dashboard has nothing to show—for example, an empty chart or a loading state.

To display site performance data on a dashboard:

  1. Call List Semantic Models to retrieve all available semantic models and their IDs, to populate a model picker.
  2. Identify the model relevant to the use case from the returned list.
  3. Call Get Semantic Model with the model's ID to inspect its available measures, dimensions, and parameters and display them.
  4. Identify the measures, dimensions, and parameters relevant to the use case from the model's schema.
  5. Call Query Semantic Model Data with the desired field names, a time interval, and any filters. Set formattingEnabled to true to receive human-readable values (for example, "$1,500.00" instead of 1500). Render the returned rows on the dashboard to replace the loading state.

Build a custom analytics report with aggregated totals

This flow generates a report showing analytics data for a specific time period, along with aggregated totals for the full period. For example, both a daily revenue breakdown and the overall total revenue.

Before the flow runs, the report view is empty—no rows and no totals.

To build a custom analytics report with aggregated totals:

  1. Call List Semantic Models to retrieve all available semantic models and their IDs, to populate a model picker.
  2. Identify the model relevant to the report's subject area from the returned list.
  3. Call Get Semantic Model with the model's ID to inspect its available measures, dimensions, and parameters and display them.
  4. Identify the measures and dimensions relevant to the report from the model's schema.
  5. Call Query Semantic Model Data with the relevant field names, a time interval, sorting, pagination, and totalsIncluded set to true.
  6. Use the results array for the row-by-row data breakdown and the totals field for the aggregated sum across the full (unpaginated) result set. The report then shows the per-row breakdown and a totals row.
Did this help?