> ## Documentation Index
> Fetch the complete documentation index at: https://help.treble.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# fact_target_events

> Conversion and goal events fired inside conversation flows.

# fact\_target\_events

Each row is one target (goal/conversion) event fired by a conversation flow — the moment a user reached a node you marked as a goal: completed a purchase intent, confirmed an appointment, qualified as a lead.

## What questions does it answer?

* How many conversions did each flow generate?
* Which specific users converted, and when?
* What is the conversion rate of a campaign (join with sends or sessions)?

## Columns

| Column            | Type       | Description                                                                  |
| ----------------- | ---------- | ---------------------------------------------------------------------------- |
| `event_id`        | Int64      | Unique identifier of the event                                               |
| `company_id`      | Int32      | Your company (filtered automatically)                                        |
| `session_id`      | Int64      | The conversation flow where it fired                                         |
| `target_event_id` | Int32      | Identifier of the target event definition — the key to distinguish events    |
| `node_id`         | Int32      | The flow node the target event is attached to                                |
| `question_text`   | String     | Text of the question at that node — the most descriptive label for the event |
| `poll_id`         | Int32      | Flow identifier; `0` if unresolved                                           |
| `poll_name`       | String     | Flow name                                                                    |
| `cellphone`       | String     | User's phone number                                                          |
| `created_at`      | DateTime64 | When the event fired                                                         |
| `synced_at`       | DateTime64 | When this row was last written/corrected                                     |

## Example queries

### Conversions per flow, last 30 days

```sql theme={null}
SELECT poll_name, target_event_id, any(question_text) AS step, count() AS conversions
FROM fact_target_events
WHERE created_at >= today() - 30
GROUP BY poll_name, target_event_id
ORDER BY conversions DESC
```

### Conversion rate of one flow

```sql theme={null}
SELECT
    uniqExact(t.session_id)                          AS converted_sessions,
    (SELECT count() FROM fact_treble_sessions
     WHERE poll_id = {your_poll_id}
       AND created_at >= today() - 30)               AS total_sessions,
    round(100.0 * converted_sessions / total_sessions, 1) AS conversion_pct
FROM fact_target_events AS t
WHERE t.poll_id = {your_poll_id}
  AND t.created_at >= today() - 30
```
