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

# Real-Time Analytics

> Track deliverability, opens, clicks, and engagement metrics across all channels

## Overview

Transmit provides comprehensive real-time analytics to help you understand and optimize your communication performance. Track every message from send to delivery, monitor engagement, and gain insights to improve your campaigns.

## Why Real-Time Analytics?

<CardGroup cols={2}>
  <Card title="Instant Visibility" icon="eye">
    See delivery status and engagement the moment it happens
  </Card>

  <Card title="Optimize Performance" icon="chart-up">
    Identify what works and refine your messaging strategy
  </Card>

  <Card title="Troubleshoot Issues" icon="wrench">
    Quickly detect and resolve delivery problems
  </Card>

  <Card title="Unified Dashboard" icon="gauge">
    Track email, SMS, and voice metrics in one place
  </Card>
</CardGroup>

## Dashboard Analytics

### Overview Metrics

Get a high-level view of your communication performance:

* **Total messages sent** across all channels
* **Delivery rate** (successfully delivered / sent)
* **Engagement rate** (opens + clicks / delivered)
* **Bounce rate** (bounced / sent)
* **Cost tracking** and credit consumption
* **Hourly, daily, and monthly trends**

### Channel-Specific Metrics

**Email Analytics**

* Sent, delivered, bounced, failed counts
* Open rate and unique opens
* Click rate and click-through rate (CTR)
* Spam complaint rate
* Time-to-open analysis
* Device and client breakdown
* Geographic distribution

**SMS Analytics**

* Messages sent and delivered
* Delivery rate by carrier
* Opt-out rate
* Message segment distribution
* Cost per message
* Time-to-delivery

**Voice Analytics**

* Calls initiated and answered
* Answer rate
* Average call duration
* Failed call reasons
* Cost per minute
* Peak calling hours

## API Analytics

Retrieve analytics programmatically for custom reporting and integrations:

### Get Email Analytics

<CodeGroup>
  ```typescript TypeScript theme={null}
  // Get email analytics for a date range
  const analytics = await client.analytics.emails({
    startDate: '2025-01-01',
    endDate: '2025-01-31',
    groupBy: 'day' // 'hour', 'day', 'week', 'month'
  });

  console.log('Total sent:', analytics.totalSent);
  console.log('Delivery rate:', analytics.deliveryRate);
  console.log('Open rate:', analytics.openRate);
  console.log('Click rate:', analytics.clickRate);
  ```

  ```bash cURL theme={null}
  curl -X GET "https://api.transmit.dev/v1/analytics/emails?startDate=2025-01-01&endDate=2025-01-31&groupBy=day" \
    -H "Authorization: Bearer tx_your_api_key_here"
  ```
</CodeGroup>

<Info>
  SDK examples currently use TypeScript. We'll add Python snippets as soon as the Python SDK is released.
</Info>

### Response Format

```json theme={null}
{
  "totalSent": 15420,
  "delivered": 15198,
  "bounced": 142,
  "failed": 80,
  "opened": 8234,
  "clicked": 2156,
  "deliveryRate": 0.986,
  "openRate": 0.542,
  "clickRate": 0.142,
  "clickToOpenRate": 0.262,
  "bounceRate": 0.009,
  "spamRate": 0.002,
  "timeline": [
    {
      "date": "2025-01-01",
      "sent": 523,
      "delivered": 515,
      "opened": 278,
      "clicked": 72
    }
    // ... more data points
  ]
}
```

### Filter by Tags

Track performance of specific campaigns or message types:

```typescript theme={null}
const analytics = await client.analytics.emails({
  startDate: '2025-01-01',
  endDate: '2025-01-31',
  tags: ['newsletter', 'promotional']
});
```

### Filter by Domain

Analyze performance by recipient domain:

```typescript theme={null}
const analytics = await client.analytics.emails({
  startDate: '2025-01-01',
  endDate: '2025-01-31',
  recipientDomain: 'gmail.com'
});
```

## Real-Time Event Tracking

Track individual message events in real-time:

### Email Events

| Event                | Description                      | When It Fires                 |
| -------------------- | -------------------------------- | ----------------------------- |
| `email.queued`       | Email accepted for sending       | Immediately after API call    |
| `email.sent`         | Email sent to recipient's server | Within seconds                |
| `email.delivered`    | Email confirmed delivered        | 1-30 seconds after send       |
| `email.opened`       | Recipient opened the email       | When tracking pixel loads     |
| `email.clicked`      | Recipient clicked a link         | When tracked link is clicked  |
| `email.bounced`      | Email bounced back               | 1-60 seconds after send       |
| `email.complained`   | Marked as spam                   | When recipient reports spam   |
| `email.unsubscribed` | Recipient unsubscribed           | When unsubscribe link clicked |

### SMS Events

| Event              | Description              | When It Fires              |
| ------------------ | ------------------------ | -------------------------- |
| `sms.queued`       | SMS accepted for sending | Immediately after API call |
| `sms.sent`         | SMS sent to carrier      | Within seconds             |
| `sms.delivered`    | SMS delivered to device  | 1-60 seconds after send    |
| `sms.failed`       | SMS failed to deliver    | 1-60 seconds after send    |
| `sms.unsubscribed` | Recipient sent STOP      | When STOP keyword received |

### Voice Events

| Event             | Description       | When It Fires               |
| ----------------- | ----------------- | --------------------------- |
| `voice.initiated` | Call initiated    | Immediately                 |
| `voice.ringing`   | Phone is ringing  | 1-5 seconds                 |
| `voice.answered`  | Call was answered | When recipient picks up     |
| `voice.completed` | Call completed    | When call ends              |
| `voice.busy`      | Line was busy     | Immediately                 |
| `voice.no_answer` | No answer         | After timeout (usually 30s) |
| `voice.failed`    | Call failed       | When error occurs           |

## Webhooks for Real-Time Notifications

Receive instant notifications for all events:

### Setup

1. Configure webhook endpoint in your dashboard
2. Select events to receive
3. Verify webhook signature for security

### Example Webhook Handler

<CodeGroup>
  ```typescript TypeScript theme={null}
  import express from 'express';

  const app = express();
  app.use(express.json());

  app.post('/webhooks/transmit', async (req, res) => {
    const { event, channel, data } = req.body;

    // Log event to your analytics system
    await logToAnalytics({
      event,
      channel,
      messageId: data.id,
      timestamp: data.timestamp,
      metadata: data
    });

    // Update your database
    if (event === 'email.delivered') {
      await updateEmailStatus(data.id, 'delivered');
    } else if (event === 'email.opened') {
      await trackEngagement(data.id, 'opened');
    }

    res.status(200).send('OK');
  });
  ```
</CodeGroup>

<Info>
  TypeScript examples are available today. Python webhook examples will be added alongside the Python SDK release.
</Info>

## Engagement Tracking

### Email Open Tracking

Transmit automatically tracks email opens using an invisible tracking pixel:

```typescript theme={null}
const response = await client.emails.send({
  from: 'hello@yourdomain.com',
  to: 'user@example.com',
  subject: 'Product Update',
  html: '<h1>New Features</h1>',
  tracking: {
    opens: true // Enable open tracking
  }
});
```

**How it works:**

* Invisible 1x1 pixel image inserted into email
* Pixel loads when email is opened
* Event fired to your webhooks
* Tracked in dashboard analytics

**Limitations:**

* Requires images to be enabled in email client
* May not track all opens (privacy features)
* Multiple opens may be tracked if email reopened

### Link Click Tracking

Track which links recipients click:

```typescript theme={null}
const response = await client.emails.send({
  from: 'hello@yourdomain.com',
  to: 'user@example.com',
  subject: 'Check out our sale!',
  html: '<a href="https://example.com/sale">Shop Now</a>',
  tracking: {
    clicks: true // Enable click tracking
  }
});
```

**How it works:**

* Links automatically wrapped with tracking URLs
* Recipient redirected through tracking server
* Click event recorded and fired
* Recipient lands on intended destination

**Data captured:**

* Link URL clicked
* Timestamp
* User agent and device info
* Geographic location (IP-based)

## Geographic Analytics

Understand where your messages are being delivered and opened:

```typescript theme={null}
const geoAnalytics = await client.analytics.geographic({
  channel: 'email',
  startDate: '2025-01-01',
  endDate: '2025-01-31'
});

// Returns breakdown by country/region
console.log(geoAnalytics.byCountry);
// [
//   { country: 'US', sent: 10234, opened: 5421 },
//   { country: 'UK', sent: 2341, opened: 1203 },
//   ...
// ]
```

## Device & Client Analytics

See what devices and email clients your recipients use:

```typescript theme={null}
const deviceAnalytics = await client.analytics.devices({
  startDate: '2025-01-01',
  endDate: '2025-01-31'
});

console.log(deviceAnalytics.byClient);
// [
//   { client: 'Gmail', opens: 3421, percentage: 0.42 },
//   { client: 'Apple Mail', opens: 2341, percentage: 0.29 },
//   { client: 'Outlook', opens: 1567, percentage: 0.19 },
//   ...
// ]

console.log(deviceAnalytics.byDevice);
// [
//   { device: 'Mobile', opens: 4532, percentage: 0.56 },
//   { device: 'Desktop', opens: 2987, percentage: 0.37 },
//   { device: 'Tablet', opens: 543, percentage: 0.07 }
// ]
```

## Performance Insights

### Deliverability Score

Transmit calculates a deliverability score based on:

* Delivery rate
* Bounce rate
* Spam complaint rate
* Domain reputation
* Historical performance

```typescript theme={null}
const score = await client.analytics.deliverabilityScore();

console.log(score.overall); // 0.0 - 100.0
console.log(score.breakdown);
// {
//   deliveryRate: 98.6,
//   bounceRate: 0.9,
//   spamRate: 0.2,
//   domainReputation: 95.0
// }
```

### Send Time Optimization

Find the best times to send messages:

```typescript theme={null}
const timeAnalytics = await client.analytics.sendTimes({
  channel: 'email',
  metric: 'openRate' // or 'clickRate'
});

console.log(timeAnalytics.bestTimes);
// [
//   { hour: 10, day: 'Tuesday', openRate: 0.67 },
//   { hour: 14, day: 'Wednesday', openRate: 0.64 },
//   ...
// ]
```

## Cost Analytics

Track spending across all channels:

```typescript theme={null}
const costAnalytics = await client.analytics.costs({
  startDate: '2025-01-01',
  endDate: '2025-01-31',
  groupBy: 'channel'
});

console.log(costAnalytics.byChannel);
// [
//   { channel: 'email', messages: 15420, cost: 7.71 },
//   { channel: 'sms', messages: 3421, cost: 34.21 },
//   { channel: 'voice', messages: 234, cost: 23.40 }
// ]
```

## Export Analytics

Export analytics data for external analysis:

```typescript theme={null}
// Export to CSV
const csvData = await client.analytics.export({
  format: 'csv',
  startDate: '2025-01-01',
  endDate: '2025-01-31',
  channel: 'email'
});

// Export to JSON
const jsonData = await client.analytics.export({
  format: 'json',
  startDate: '2025-01-01',
  endDate: '2025-01-31',
  includeEvents: true
});
```

## Best Practices

<CardGroup cols={2}>
  <Card title="Track Strategically" icon="bullseye">
    Enable tracking only when you need it. Respect user privacy.
  </Card>

  <Card title="Monitor Trends" icon="chart-line">
    Look at trends over time, not just absolute numbers. Watch for sudden changes.
  </Card>

  <Card title="Segment Your Data" icon="filter">
    Use tags and filters to understand performance by campaign, audience, or type.
  </Card>

  <Card title="Act on Insights" icon="lightbulb">
    Use analytics to make decisions. Test different approaches and measure results.
  </Card>

  <Card title="Set Up Alerts" icon="bell">
    Configure webhooks to get notified of anomalies or important events.
  </Card>

  <Card title="Clean Your Lists" icon="broom">
    Remove bounced addresses and unsubscribed contacts to maintain sender reputation.
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Webhooks" href="/docs/guides/webhooks" icon="webhook">
    Set up real-time event notifications
  </Card>

  <Card title="Multi-Channel" href="/docs/guides/multi-channel" icon="messages">
    Compare analytics across channels
  </Card>

  <Card title="API Reference" href="/api-reference/analytics" icon="book">
    Complete analytics API documentation
  </Card>

  <Card title="Dashboard" href="https://transmit.dev/dashboard/analytics" icon="gauge">
    View analytics in the dashboard
  </Card>
</CardGroup>
