Skip to content

Confguring Facebook Ads Extractor

Tomas Kacur edited this page Jan 31, 2017 · 5 revisions

###1. Create config and authorize fb account After creating a config of keboola.ex-facebook-ads component, authorize your facebook ads account in ui of created configuration

2. Get the list of ad accounts

List ad accounts via call POST https://docker-runner.keboola.com/docker/keboola.ex-facebook-ads/action/adaccounts with sapi token(x-storageapi-token) in the header and body:

{
  "configData": {
    "authorization": {
      "oauth_api": {
        "id": "<configId>"
      }
    }
  }
}

replace the <configId> with actual id of created config of keboola.ex-facebook-ads. You should get response as following:

[
  {
    "account_id": "310918693",
    "id": "act_310918693", 
    "business_name": "",
    "name": "Tomas Kacurez"
  }
]

3. Save configuration json

Here extracts ads(query name ads), campaigns(query name campaigns), ads insights(query name ads_insights) and adsets (query name adsets)

{
  "accounts": {
    "act_310918693": {
      "account_id": "310918693",
      "id": "act_310918693",    
      "business_name": "",
      "name": "Tomas Kacurez"
    }
  },
  "api-version": "v2.8",
  "queries": [
    {
      "id": 1,
      "name": "ads",
      "type": "nested-query",
      "query": {
        "path": "ads",
        "fields": "id,name,adset_id",
        "ids": "act_310918693"
      }
    },
    {
      "id": 2,
      "name": "campaigns",
      "type": "nested-query",
      "query": {
        "path": "campaigns",
        "fields": "id,name,account_id",
        "ids": "act_310918693"
      }
    },
    {
      "id": 3,
      "name": "ads_insights",
      "type": "nested-query",
      "query": {
        "path": "ads",
        "fields": "insights.action_breakdowns(action_type).date_preset(last_month).time_increment(1){ad_id,impressions,reach,actions,clicks,spend}",
        "ids": "act_310918693"
      }
    },
    {
      "id": 4,
      "name": "adsets",
      "type": "nested-query",
      "query": {
        "path": "adsets",
        "fields": "id,name,campaign_id",
        "ids": "act_310918693"
      }
    }
  ]
}

the following table is the configuration of the old fb ads extractor to extract the same data:

|endpoint         |params|dataType|dataField|recursionParams|rowId|
|------------------------------------------------------------------
|act_xxx/ads      |{"fields":"id,name,adset_id"}|ads|data||4|
|act_xxx/campaigns|{"fields":"id,name,account_id"}|campaigns|data||2|
|{4:id}/insights  |{"fields":"ad_id,impressions,reach,actions,clicks,spend","action_breakdowns":"action_type","date_preset":"last_month","time_increment":"1"}|ads_insights|data||5|
|act_xxx          |{"fields":"account_id,business_name"}|accounts|.||1|
|act_xxx/adsets   |{"fields":"id,name,campaign_id"}|adsets|data||3|

The resulting data structure may vary but the data it self should be the same.