Skip to content

Ad accounts

An ad account connection links one advertising account on Meta, Google Ads or TikTok to one of your analytics sites. Once connected, amabledata:

  • imports the account’s daily spend, clicks, impressions and the conversions the platform itself reports (see Ad spend sync);
  • can send conversions back to the platform server-side (see Server-side conversions).

Connections are managed per site in Analytics › Overview › Analytics settings, tab Ad accounts (URL /t/<workspace>/analytics/settings?tab=ads). Pick the site with the site picker in the toolbar first: every site has its own connections.

The same tab also contains the Conversions sent log, documented in Server-side conversions.

Three platforms are supported. Each one appears as a card in the Ad accounts panel:

Card Platform What a connection unlocks
Meta Meta ads (Facebook, Instagram) Spend import, server-side conversions
Google Ads Google Ads Spend import, server-side click conversions
TikTok TikTok ads Spend import, server-side conversions

Connections go through OAuth: you sign in on the ad platform and authorize amabledata to read your ad accounts. The OAuth app used for that sign-in belongs to whoever operates the installation:

  • On the managed cloud, the operator has configured the apps. You only click Connect.
  • On a self-hosted installation, you create your own app on each platform and set its credentials as secrets of the core worker. See OAuth apps.

A platform without credentials shows the line Not configured on this installation. under its name and its Connect button is disabled (hovering it shows the same text). Other platforms keep working: you can configure them one at a time.

The credentials read by the core worker are:

Platform Required variables Optional
Meta META_APP_ID, META_APP_SECRET
Google Ads GOOGLE_ADS_CLIENT_ID, GOOGLE_ADS_CLIENT_SECRET, GOOGLE_ADS_DEVELOPER_TOKEN GOOGLE_ADS_LOGIN_CUSTOMER_ID (manager account, digits; dashes are removed)
TikTok TIKTOK_APP_ID, TIKTOK_APP_SECRET

Every platform redirects back to one fixed callback page of the dashboard: <APP_ORIGIN>/oauth/ads/callback. You can override it with the ADS_OAUTH_REDIRECT_URI variable. The URL registered on the platform app must match it exactly (scheme, host and path).

A single authorization can give access to several ad accounts. When you complete the OAuth flow, amabledata creates one connection per ad account the authorization can see, up to 25 accounts per authorization. Each connection row shows:

  • the account name (or the account id when the platform returned no name);
  • a status pill;
  • the account id, the account currency when the platform reported a valid ISO code, and synced followed by the relative time of the last successful sync (or never);
  • on Meta and TikTok rows that are not disconnected, where server-side conversions go: the dataset or pixel, for example Dataset (pixel) ID: 1234567890 (Meta) or Pixel code: C4ABCDEF (TikTok), followed by · test mode while a test event code is set; or, when nothing is set, the amber warning No dataset or pixel set: server-side conversions to this account cannot be sent.;
  • the last error, in a red box, when the last attempt failed.

The connection id is derived from the platform and the account id, so reconnecting the same account later updates the same connection instead of creating a duplicate. Spend already imported stays attached to it.

The time zone of the ad account is stored with the connection: spend days and the daily reconciliation follow the account’s own day boundary.

Access and refresh tokens never reach the browser. They are stored encrypted in the installation database, bound to the workspace, the site and the authorization. Access tokens are refreshed automatically when they are less than 2 hours from expiry. The site’s analytics storage only keeps the account, its status and a reference to the authorization.

Status pill Meaning What moves a connection here What happens
Active The connection works. A successful connect, sync or backfill. Spend sync runs on schedule; conversions can be sent.
Reconnect needed The platform rejected the authorization (expired or revoked token, HTTP 401/403, or missing authorization). A sync, backfill or conversion send that fails with an authorization error. Spend sync is paused. Conversions waiting for this account stay queued and are retried with backoff until they run out of attempts. Owners and admins of the workspace receive an email. The card’s button becomes Reconnect.
Error A permanent error that is not about authorization (for example the platform rejected the request, or the platform is no longer configured on the installation). A sync that fails with a permanent error. The sync is retried at most once per hour. The error text is shown under the account.
Disconnected You disconnected the account. Disconnect. No sync, no conversions. The row stays visible without buttons; imported spend is kept.

Temporary platform problems (timeouts, HTTP 429 or 5xx) do not change the status: the error text is recorded and the sync is retried at the next 5-minute tick.

The “reconnect” email is sent once, when the connection first enters Reconnect needed, to every member with the owner or admin role. Its subject reads [amabledata] Reconnect <platform> ads on <site name> and its body explains that spend sync is paused until the account is reconnected.

  1. Open Analytics › Overview, then Analytics settings, and select the Ad accounts tab.
  2. Choose the site in the site picker.
  3. On the card of the platform, click Connect. You are redirected to the platform’s sign-in and consent screen.
  4. Sign in with a user that has access to the ad accounts you want, and approve the requested permissions.
  5. The platform sends you back to the callback page, which shows Connecting the ad account…. amabledata exchanges the code, creates one connection per accessible ad account and runs a first sync of each one (today plus the previous 7 days).
  6. You land back on the Ad accounts tab with the toast Ad account connected. The new rows appear under the platform card.

When a row shows Reconnect needed, the platform card’s button reads Reconnect. Click it and complete the OAuth flow again with a user that still has access to the account. The existing connection returns to Active (same connection, same history) and a sync runs immediately.

Set the dataset or pixel (Meta and TikTok)

Section titled “Set the dataset or pixel (Meta and TikTok)”

Meta sends server-side conversions to a dataset (pixel) and TikTok to a pixel, which the OAuth connection does not pick for you. Set it on each Meta or TikTok row with the Conversions button: see Server-side conversions › Set the dataset or pixel of an ad account. Google Ads needs nothing here: conversions go to the connected account and to the conversion action you map on the traffic source.

Use Backfill on an account row to pull an older or corrected range again. See Ad spend sync › Re-import a date range.

  1. On the account row, click Disconnect.
  2. The dialog Disconnect <account>? explains: Spend sync and conversion sending stop. Imported spend is kept.
  3. Click Disconnect to confirm. The toast Ad account disconnected appears and the row switches to Disconnected.

The stored authorization is deleted as soon as no other active connection of the site uses it. To also revoke access on the platform side, remove the app from your account’s permissions on Meta, Google or TikTok.

Element Description
Hint Connect ad accounts to import spend and send conversions back server-side.
Platform card One per platform: Meta, Google Ads, TikTok.
Connect / Reconnect Starts OAuth. Shows Reconnect when at least one account of the platform needs it. Hidden without the configuration permission; disabled when the platform is not configured.
No account connected. Empty state of a card.
Account row Name, status pill, account id, currency, synced …, dataset or pixel (Meta, TikTok), last error.
Conversions Meta and TikTok rows only: opens Server-side conversions to set the dataset (pixel) ID or pixel code and the test event code. Not shown on disconnected rows.
Backfill Opens Re-import spend. Not shown on disconnected rows.
Disconnect Opens the confirmation dialog. Not shown on disconnected rows.

The page at /oauth/ads/callback has no navigation. It shows a spinner with Connecting the ad account…, then either returns to the tab or shows The connection did not complete with a reason and a Back to ad accounts link.

Message Cause
The authorization was refused on the ad platform. You cancelled or denied consent on the platform (it returned an error).
The link is incomplete: start the connection again. The callback URL has no state or code, or the workspace cannot be read from state.
This authorization was started in another tab or expired: start the connection again. The pending connection is not in this tab’s session storage (other tab, storage disabled, page reloaded after completion).
invalid or expired authorization The server-side state expired (10 minutes), was already used, or belongs to another site or platform; or the platform rejected the code.
no ad account available for this authorization The signed-in user has no ad account the app can read.

All endpoints are under /api/v2/t/<workspace>/analytics and take site_id as a query parameter.

Method and path Permission Purpose
GET /ads/connections analytics:read Lists connections plus available (configured platforms) and fake (development mode). Tokens are never returned.
POST /ads/connections/{platform}/connect analytics:configure Returns authorize_url and state.
POST /ads/connections/{platform}/callback analytics:configure Body { state, code, account_ids? }. account_ids (1–25) narrows the accounts to connect; default is every account. Runs the first sync.
PATCH /ads/connections/{id} analytics:configure Meta and TikTok only. Body { pixel_id?, test_event_code? }: the dataset (pixel) ID or pixel code (4–64 letters, digits, _ or -) and the test event code (1–64 of the same characters); null clears a field, an omitted field is left as is. Returns the connection with pixel_id and test_event_code. On Google Ads it fails with this platform takes no pixel settings.
DELETE /ads/connections/{id} analytics:configure Disconnects; spend and entities are kept.
POST /ads/connections/{id}/backfill analytics:configure Body { from, to } (YYYY-MM-DD, at most 90 days).

Connecting, changing the conversion settings, disconnecting and backfilling write the audit events analytics.ads_connected, analytics.ads_settings_updated, analytics.ads_disconnected and analytics.ads_backfilled.

Action Permission Roles that have it by default
See the tab and connection statuses analytics:read Owner, admin, marketer, analyst, viewer
Connect, reconnect, set the dataset or pixel, backfill, disconnect analytics:configure Owner, admin, marketer

Users without analytics:configure see the banner You can view these settings; changing them needs the analytics configuration permission. and no buttons.

Limit Value
Ad accounts connected per authorization 25
OAuth state lifetime 10 minutes
Token refresh margin 2 hours before expiry
Symptom Cause Fix
Not configured on this installation. and a disabled Connect The installation has no OAuth app credentials for that platform. Self-hosted: set the variables listed above on the core worker (OAuth apps). Cloud: contact support.
Toast Ad platform integrations are not configured on this installation. Same cause, reached through the API. As above.
Toast The authorization expired: reconnect the account. The platform rejected the token during a backfill. Click Reconnect and complete OAuth again.
Toast The ad platform did not answer. Try again in a moment. The platform timed out, rate-limited or returned a server error. Retry later.
The platform shows a “redirect URI mismatch” error The callback URL registered on the app differs from <APP_ORIGIN>/oauth/ads/callback (or ADS_OAUTH_REDIRECT_URI). Register the exact URL on the platform app.
Row stuck on Reconnect needed The user who authorized lost access, changed password, or removed the app. Reconnect with a user that has access.
Row on Error with integration_unavailable The platform’s credentials were removed from the installation after connecting. Restore the credentials; the next hourly retry clears it.
Amber No dataset or pixel set: server-side conversions to this account cannot be sent. on a Meta or TikTok row The dataset (pixel) ID or pixel code is not set. Click Conversions on the row and enter it.
Fewer accounts than expected Only accounts the signing-in user can access are connected, at most 25 per authorization. Sign in with a user that has access, or connect again for the remaining accounts.