This commit is contained in:
JiriUhlir
2026-06-18 12:26:15 +02:00
parent 6934f22253
commit 9cd5c8011b
3 changed files with 102 additions and 5 deletions
+24
View File
@@ -23,6 +23,30 @@ The service account (or token) must have access to the GA4 property — add its
> `[Convert]::ToBase64String([IO.File]::ReadAllBytes("service-account.json"))`
> (PowerShell).
## Kde získat údaje (návod pro klienta)
**ID property** (`property_id` v URL): GA4 → **Administrace → Nastavení
property** → *ID property* (např. `123456789`).
**A) Service account doporučeno (`X-GA-Credentials`)**
1. [Google Cloud Console](https://console.cloud.google.com/) → projekt.
2. **APIs & Services → Library** → povolit **Google Analytics Data API** a
**Google Analytics Admin API**.
3. **IAM & Admin → Service Accounts → Create service account**.
4. U účtu **Keys → Add key → JSON** → stáhne se klíč.
5. `client_email` z JSON přidat v GA4 **Administrace → Správa přístupu k
property** jako **Viewer**.
6. JSON zakódovat do base64 (viz výše) → hlavička `X-GA-Credentials`.
**B) Hotový OAuth2 token rychlý test (`X-GA-Access-Token`)**
1. [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/).
2. Scope `https://www.googleapis.com/auth/analytics.readonly` → **Authorize
APIs** (Google účet s přístupem k property).
3. **Exchange authorization code for tokens***Access token* → hlavička
`X-GA-Access-Token` (platí ~1 h).
## Data API endpoints
`property_id` may be the bare number (`123456789`) or `properties/123456789`.