# plugin-marketing

`@fayz-ai/plugin-marketing` · beta · Partial capability

Marketing analytics are always the same shape — channels, campaigns, a funnel, landing-page CVR — but what counts as a "conversion" changes per business. A salon converts a booking, a store converts an order, an agency converts a lead. plugin-marketing is one plugin that adapts to all of them: pick a domain preset (or pass an explicit conversion model + channels) and the funnel, channel…

## Specs

- **Package:** `@fayz-ai/plugin-marketing`
- **Version:** 0.2.1
- **Status:** beta
- **Capability:** Partial capability
- **Product type:** Management (Admin/SaaS)
- **Stable channel:** `^0.2.1`
- **Migrations:** 4 migration(s)
- **Factory:** `createMarketingPlugin()`

## Data model

Convention: plg_ + tenant_id + RLS.

- `plg_marketing_social_accounts` — name, handle, platform, is_active
- `plg_marketing_content_plans` — account_id, name, status, weeks_count, start_date, objective
- `plg_marketing_content_posts` — plan_id, week_number, position, title, format, status
- `plg_marketing_ranklayer_integrations` — api_key, site_domain, active, last_sync_at
- `plg_marketing_ranklayer_sync_log` — integration_id, status, message, fetched, written
- `plg_marketing_channels` — channel_key, label, icon, kind, is_active, monthly_spend
- `plg_marketing_campaigns` — name, channel_key, status, starts_at, ends_at, spend

## AI tools

| id | mode | description |
| --- | --- | --- |
| `marketing.channel-performance` | read | Returns acquisition performance per channel (reach, conversions, CVR, spend, CPA). |
| `marketing.top-channels` | read | Returns the top acquisition channels ranked by conversions. |
| `marketing.campaign-cvr` | read | Lists campaigns with their conversion rate for a date range. |
| `marketing.create-campaign` | persist | Creates an acquisition campaign on a channel. Resolve the channel first via queryData/searchRecords on marketing channels (use its channel key). The user confirms before creating. |

## Integrations

No hosted connector — external providers come in via the connector spine (`@fayz-ai/core`).

## Integrate

Add the plugin to surfaces.admin.plugins in your app's app.manifest.json and run the doctor to validate:

```json
{ "surfaces": { "admin": { "plugins": [ { "id": "marketing", "enabled": true } ] } } }
```

```bash
npx fayz doctor
```
