# POST /websites/:website_id/google-analytics-setup

**Resource:** [Websites](./websites.md)  
**MCP tool:** `set_up_website_google_analytics`  
**Scopes:** `websites:write`  
**Write operation:** yes

Set up Google Analytics for a website in one call: finds the right property (the website's linked one, the one its current tag sends to, or one whose web stream is the website's address) or creates one, adds the website as a web stream, marks generate_lead, book_appointment, purchase as key events, switches the tag on through TrustPager's site code, and links the website so get_website_google_analytics_traffic and the Traffic tab read it. Safe to run again. tag is "on_site" when the site code is on the website, or "needs_site_code" (get_website_connection has the copy-paste code). Answers 409 NO_ACCOUNT when the Google account has no Analytics account (create_google_analytics_account first), and 409 CHOOSE_ACCOUNT when a new property is needed and it has several (pass account_id). Needs edit access: without it the answer is 409 MANAGE_ACCESS_NEEDED with the link a workspace admin opens to allow it (get_google_analytics_manage_link).

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `website_id` | path | string | yes | UUID of the website. Get ids from list_websites. |
| `account_id` | body | string | no | Only when a new property is needed and the Google account has several Google Analytics accounts: which one to put it in. |
| `property_id` | body | string | no | Use this property instead of finding or creating one. |
| `replace_tag` | body | boolean | no | Only when the website already sends to a measurement id the connected Google account cannot see: true moves it to this property. |
| `require_approval` | body | boolean | no | Optional. Set true to route this write into the approval queue for human review instead of executing it immediately (returns 202 + an approval_id). Works even when your key/token has permission to execute directly. |

## Request example

```bash
curl -X POST   "https://api.trustpager.com/functions/v1/api/v1/websites/:website_id/google-analytics-setup"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"account_id":"...","property_id":"...","replace_tag":"..."}'
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`