Loading...
Loading...
Query Google Ads campaigns, ad groups, keywords and spend via the Google Ads API (GAQL searchStream). Use when the user mentions Google Ads, ad campaigns, ad spend / cost, impressions / clicks / conversions on ads, or campaign performance.
npx skill4agent add acedatacloud/skills google-adscurl + jq$GOOGLE_ADS_TOKENadwordsAuthorization: Bearer $GOOGLE_ADS_TOKEN$GOOGLE_ADS_DEVELOPER_TOKENdeveloper-token: $GOOGLE_ADS_DEVELOPER_TOKENlogin-customer-id$GOOGLE_ADS_LOGIN_CUSTOMER_IDAPI version: the base is. Google ships a newhttps://googleads.googleapis.com/<vNN>every ~4 months and retires old ones — setvNNto the current supported version (check developers.google.com/google-ads/api release notes); the example usesVER.v18
$GOOGLE_ADS_DEVELOPER_TOKENVER="v18"; BASE="https://googleads.googleapis.com/$VER"
AUTH="Authorization: Bearer $GOOGLE_ADS_TOKEN"; DEV="developer-token: $GOOGLE_ADS_DEVELOPER_TOKEN"
# Customers the OAuth user can access (ids are returned as customers/<id>)
curl -sS -H "$AUTH" -H "$DEV" "$BASE/customers:listAccessibleCustomers" | jq '.resourceNames'CID="1234567890" # target customer id, digits only
curl -sS -H "$AUTH" -H "$DEV" -H "login-customer-id: ${GOOGLE_ADS_LOGIN_CUSTOMER_ID:-$CID}" \
-H "Content-Type: application/json" -d '{
"query":"SELECT campaign.name, metrics.cost_micros, metrics.clicks, metrics.conversions FROM campaign WHERE segments.date DURING LAST_30_DAYS ORDER BY metrics.cost_micros DESC"
}' "$BASE/customers/$CID/googleAds:searchStream" \
| jq '.[].results[]? | {campaign: .campaign.name, cost_usd: (.metrics.costMicros|tonumber/1e6), clicks: .metrics.clicks, conv: .metrics.conversions}'campaignad_groupad_group_criterioncustomermetrics.cost_microsdeveloper-tokenlogin-customer-id123-456-7890searchStream.results[].[].results[]?