Composable Audience Studio (CAS) runs segmentation, activation, and supporting queries directly on your Snowflake account, using your warehouse's compute. To keep that usage transparent, Composable Audience Studio sets a structured, JSON-formatted Snowflake QUERY_TAG on the queries it issues. The tag records which application ran the query, which parent segment, segment, or activation it belongs to, and what kind of operation it was — so you can separate Composable Audience Studio workloads from the rest of your Snowflake activity, attribute compute costs to individual audiences, segments, and activations, and set up monitoring or chargeback directly in Snowflake.
Query tagging requires no configuration. Tags appear automatically in your Snowflake query history for the operations listed on this page.
- Composable Audience Studio sets the tag on each query individually, as a request-level session parameter. Every tagged query carries the exact context (audience, segment, activation) it ran for.
- The tag is metadata only. It has no effect on query results, performance, or cost.
- Your own account-level or user-level
QUERY_TAGdefaults are not modified. Under Snowflake's parameter precedence, the request-level tag applies only to the sessions Composable Audience Studio opens. - Tags are recorded in
SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY(365-day retention, up to about 45 minutes of latency) and in theINFORMATION_SCHEMA.QUERY_HISTORYtable function (past 7 days, near real time).
The Composable Audience Studio query tag is a JSON object with the following fields:
| Field | Type | Present | Description |
|---|---|---|---|
app | string | Always | Application identifier. Fixed value: "TreasureAudienceStudio". Filter on this field to isolate all Composable Audience Studio queries. |
query_type | string | Always | The operation the query performs. See Query Types. |
td_account_id | integer | Always | The Treasure AI account ID the query runs for. |
audience_id | integer | When the query belongs to a parent segment | The parent segment (audience) ID. Omitted for queries that run before the parent segment exists, such as configuration validation. |
segment_id | integer | Segmentation and activation queries | The segment ID. Omitted for audience-level queries such as metering. |
activation_id | integer | Activation queries only | The activation ID. |
Fields that do not apply to a query are omitted from the JSON rather than set to null, so the tag stays compact and parseable.
The query_type field takes one of the following values. These values are stable — you can build dashboards and alerts on them.
| Value | Description | When It Runs |
|---|---|---|
segmentation | Evaluates segment rules to identify matching profiles | Segment preview, segment builds, profile counts for the segment rule |
activation | Exports the profiles matching a segment to a destination | Every query in an activation run, including temporary-table creation, the export read, and cleanup |
profile_lookup | Looks up an individual customer profile and its activity | Viewing a profile in the Composable Audience Studio UI |
validation | Validates schema and configuration | Parent segment and segment validation, including before the parent segment is created |
metadata | Discovers schema, lists fields, and fetches sample values | Segment builder UI, field exploration |
metering | Counts profiles for usage metering | Scheduled parent segment metering runs |
One activation run executes several Snowflake queries: creating a temporary table of matching profiles, reading it for export to the destination, and dropping it afterward. All queries in a run — including cleanup after a failure — carry the identical tag, so grouping by activation_id sums the compute cost of the whole run. Scheduled repeats and retries also carry the same tag; distinguish individual runs by query start time.
Activations configured before query tagging became available start carrying tags the next time the activation is updated.
A segmentation query, tagged with its audience and segment:
{
"app": "TreasureAudienceStudio",
"audience_id": 111,
"segment_id": 222,
"query_type": "segmentation",
"td_account_id": 12345
}An activation query additionally carries the activation ID:
{
"app": "TreasureAudienceStudio",
"audience_id": 111,
"segment_id": 222,
"activation_id": 333,
"query_type": "activation",
"td_account_id": 12345
}Because the Composable Audience Studio query tag is JSON, you can parse it in Snowflake with the TRY_PARSE_JSON() function and filter or group on any field.
List recent Composable Audience Studio queries:
SELECT START_TIME, QUERY_TEXT, QUERY_TAG
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE TRY_PARSE_JSON(QUERY_TAG):app::STRING = 'TreasureAudienceStudio'
AND START_TIME >= DATEADD('day', -7, CURRENT_TIMESTAMP())
ORDER BY START_TIME DESC;Summarize the last 7 days of Composable Audience Studio activity by query type, audience, and segment:
SELECT
TRY_PARSE_JSON(QUERY_TAG):query_type::STRING AS query_type,
TRY_PARSE_JSON(QUERY_TAG):audience_id::INTEGER AS audience_id,
TRY_PARSE_JSON(QUERY_TAG):segment_id::INTEGER AS segment_id,
COUNT(*) AS query_count,
SUM(TOTAL_ELAPSED_TIME) / 1000 AS total_elapsed_seconds,
SUM(CREDITS_USED_CLOUD_SERVICES) AS total_credits
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE TRY_PARSE_JSON(QUERY_TAG):app::STRING = 'TreasureAudienceStudio'
AND START_TIME >= DATEADD('day', -7, CURRENT_TIMESTAMP())
GROUP BY query_type, audience_id, segment_id
ORDER BY total_credits DESC;Attribute compute to individual activations:
SELECT
TRY_PARSE_JSON(QUERY_TAG):activation_id::INTEGER AS activation_id,
TRY_PARSE_JSON(QUERY_TAG):audience_id::INTEGER AS audience_id,
TRY_PARSE_JSON(QUERY_TAG):segment_id::INTEGER AS segment_id,
COUNT(*) AS query_count,
SUM(TOTAL_ELAPSED_TIME) / 1000 AS total_elapsed_seconds
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE TRY_PARSE_JSON(QUERY_TAG):app::STRING = 'TreasureAudienceStudio'
AND TRY_PARSE_JSON(QUERY_TAG):query_type::STRING = 'activation'
AND START_TIME >= DATEADD('day', -7, CURRENT_TIMESTAMP())
GROUP BY activation_id, audience_id, segment_id
ORDER BY total_elapsed_seconds DESC;ACCOUNT_USAGE.QUERY_HISTORY can lag by up to about 45 minutes. To verify a query that just ran, use the INFORMATION_SCHEMA.QUERY_HISTORY table function instead, which returns near-real-time results for the past 7 days.
- Query tags are set for Snowflake parent segments only. Queries on Databricks and BigQuery parent segments do not carry tags.
- The tag schema is fixed and system-defined. Custom fields and values are not supported.