# Ads Tracking Service

> Microservice for pixel tracking, attribution, and conversion tracking.

## Overview

Ads Tracking Service tracks user journey after ad interaction:

- **Pixel Tracking** - Website/app behavior tracking
- **Server-side Tracking** - Cookie-less Conversion API
- **Attribution** - Determine conversion source
- **Multi-touch Attribution** - Credit multiple touchpoints

## Requirements

| Requirement | Version |
|-------------|---------|
| .NET SDK | 10.0.101+ |
| Docker | 24.0+ |
| PostgreSQL/TimescaleDB | 15+ |

## Quick Start

```bash
cd services/ads-tracking-service-net
docker-compose up -d
```

## Project Structure

```
ads-tracking-service-net/
├── src/
│   ├── AdsTrackingService.API/
│   │   └── Controllers/
│   │       ├── PixelsController.cs
│   │       ├── EventsController.cs
│   │       └── ConversionsController.cs
│   │
│   ├── AdsTrackingService.Domain/
│   │   └── AggregatesModel/
│   │       ├── TrackingPixelAggregate/
│   │       ├── ConversionAggregate/
│   │       └── AttributionAggregate/
│   │
│   └── AdsTrackingService.Infrastructure/
│
└── AdsTrackingService.slnx
```

## Pixel Events

| Event | Description |
|-------|-------------|
| `PageView` | Page view |
| `ViewContent` | Product view |
| `AddToCart` | Add to cart |
| `Purchase` | Complete purchase |

## API Endpoints

### Pixels

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/ads-tracking/pixels/{advertiserId}` | Get pixel code |
| `POST` | `/api/v1/ads-tracking/pixels` | Create pixel |

### Events

| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/ads-tracking/events` | Send pixel event |
| `POST` | `/api/v1/ads-tracking/events/server` | Server-side event |

### Conversions

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/ads-tracking/conversions` | List conversions |
| `GET` | `/api/v1/ads-tracking/conversions/{id}/attribution` | Attribution details |

## Admin Office APIs

### Admin Pixels Management

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/admin/ads-tracking/pixels` | List all pixels (paginated) |
| `GET` | `/api/v1/admin/ads-tracking/pixels/{id}/events` | Pixel event history |
| `GET` | `/api/v1/admin/ads-tracking/pixels/{id}/stats` | Pixel statistics |
| `PUT` | `/api/v1/admin/ads-tracking/pixels/{id}/activate` | Activate pixel |
| `PUT` | `/api/v1/admin/ads-tracking/pixels/{id}/deactivate` | Deactivate pixel |

### Admin Conversions Analytics

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/admin/ads-tracking/conversions` | List conversions (with filters) |
| `GET` | `/api/v1/admin/ads-tracking/conversions/stats` | Conversion statistics |
| `GET` | `/api/v1/admin/ads-tracking/conversions/{id}` | Conversion details |

### Admin Attribution Reports

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/admin/ads-tracking/attribution/stats` | Attribution statistics by model |
| `GET` | `/api/v1/admin/ads-tracking/attribution/campaigns/{id}` | Campaign attribution report |

## Integration

| Service | Integration |
|---------|-------------|
| **ads-serving-service** | Consume events |
| **ads-analytics-service** | Publish conversions |

## License

Proprietary - GoodGo Platform
