SCALIX help

← All tools

lads_get_account_analytics

LinkedIn Ads read low risk

Part of the LinkedIn Campaign Manager Agent.

What it does

Account-level roll-up, pivoting on ACCOUNT via GET /rest/adAnalytics. Returns one row per ad account (or a time series when granularity is set) with impressions, clicks, costInUsd/costInLocalCurrency, landingPageClicks, oneClickLeads, externalWebsiteConversions, videoViews and videoCompletions by default; for approximateMemberReach (date ranges of 92 days or less) pass fields with approximateMemberReach plus every default metric you still want: fields replaces the default metric set, it does not add to it. ACCURACY NOTES: this is the top-of-funnel total that all CAMPAIGN/CREATIVE breakdowns must sum back to — use it to detect double-counting. Cost fields are strings (Decimal; no micros). Reconciles to Campaign Manager account totals. approximateMemberReach is an estimate — label it as approximate. Optional prior-period delta.

When to use it

During a full account audit, start with lads_audit_account — it defines the checks, benchmarks, and severity rules this tool's data feeds.

Inputs

NameTypeRequiredDescription
accountsarray<urn:li:sponsoredAccount|int>yesOne or more accounts (all within bearer scope). Bare ids wrapped to urn:li:sponsoredAccount:{id}.
date_rangestring|objectyesInclusive window {start:{year,month,day},end:{...}}. Accepts either "YYYY-MM-DD,YYYY-MM-DD" (or a single "YYYY-MM-DD" = start only) OR the object {start:{year,month,day}[, end:{year,month,day}]}; month/day are 1-based integers.
time_granularityenum(ALL|DAILY|MONTHLY|YEARLY)noDefault ALL (single total per account). MONTHLY/DAILY produce a time series.
fieldsarray<string>noOverride metric list (max 18 metrics; pivotValues and dateRange are always added and do not count). It REPLACES the default set, so list every default metric you still want. Default: pivotValues, dateRange, impressions, clicks, costInLocalCurrency, costInUsd, landingPageClicks, oneClickLeads, externalWebsiteConversions, videoViews, videoCompletions.
include_prior_periodboolnoIf true, a second call covers the equal-length window immediately before date_range (which must be 'YYYY-MM-DD,YYYY-MM-DD') and each element gains prior_period {date_range, metrics, delta_pct} matched by pivot; a zero prior yields null, never 0. A DAILY/MONTHLY/YEARLY time series (several rows per entity) skips the deltas with a warning: use time_granularity ALL.

Safeguards

Policy

Account analytics are for reporting/billing the authorizing client only; never combine or sum totals across unaffiliated accounts, and never report an account outside the bearer's scope.

Reminder

Match Campaign Manager account totals exactly, keep strict per-account isolation, and label approximateMemberReach as an estimate.

Errors

Error classMeansWhat to doRetry
CUSTOMER_NOT_FOUNDAn ad account URN does not exist or is inaccessible.Verify the account id and confirm it is authorized for the bearer; drop unknown ids.no
INVALID_ARGUMENTLinkedIn rejected a parameter (surfaced verbatim).Surface the message; correct the param.no
TOKEN_REVOKEDToken expired/revoked (HTTP 401).Refresh once and retry; else needs_reauth.yes
PERMISSION_DENIEDMissing r_ads_reporting or account out of bearer scope (HTTP 403).Confirm scope; never report out-of-scope accounts.no
RATE_LIMITEDDaily reporting quota exceeded (HTTP 429).Exponential backoff 5/10/20s cap 60s honoring X-RateLimit-Reset.yes
PLATFORM_UNAVAILABLELinkedIn returned a 5xx.Retry with backoff.yes

Edge cases

  • No activity in the window, or no read access to the data -> success with no elements and a note: report no delivery, not zeros.
  • approximateMemberReach is an estimate — label as approximate; do not reconcile it to exact UI impression counts.
  • Multi-account request returns one row per account; never sum unaffiliated accounts into a single figure.
  • LinkedIn returns at most 15,000 rows and does not page: an answer that reaches the cap (DAILY over many accounts or a long range) carries a warning that it may be cut short; narrow the window or the scope.
  • Cost strings -> Decimal.
  • Use the account total to validate that campaign/creative breakdowns sum back (double-count check).
  • Expired token -> refresh and retry once.