Campaign Metrics by Demographics / Devices / EVENTS


Hello Team,

We are trying to get Campaign Metrics with below categories from ADS API. Could you please give some examples with Analytic API Queries. Tried going over the docs but I was unable to get the exact query over there.



@ajay_api: It sounds like you’re interested in segmented stats. Please see the Metrics and Segmentation page.

In the POST stats/jobs/accounts/:account_id endpoint request, specify a segmentation_type.


Thanks Juan.
I will check the same.


Thanks for your help . !!!
I was able to download JSON file. Just want to check is there any way to get .csv file.


Sounds good, @ajay_api. Thanks for confirming.

All Ads API response bodies are in JSON. We don’t return .csv data with our stats endpoints.


Thanks for the confirmation.
While getting Segment Stats, Could you please confirm if Placement
could be passed in one request i.e.
and if we pass both placements is it aggregated internally.
If someone trying to compare with Dashboards is it recommended to make two separate requests and get different data sets or there is no such division from dashboards side.


Thanks, @ajay_api.

As our documentation states

Only a single value accepted per request. For entities with both Twitter and Twitter Audience Platform placement, separate requests are required, one for each placement value.


Thanks Juan.
Could you please give one example for getting Segment Stats for Cities . I need to know what is going to be country code/name here , I tried with USA/US but it didn’t work. Is there any another endpoint which I could get the Country/Geo codes from.

params.add(new HttpParameter(“placement”,“ALL_ON_TWITTER”));
params.add(new HttpParameter(“country”,""));
params.add(new HttpParameter(“segmentation_type”,“CITIES”));
String baseurl=“”;


Meanwhile I tried Campaign Segment Stats with Segment Type Gender for different Placements and I could see engagement and related metrics for


But couldn’t see any metrics for placement PUBLISHER_NETWORK . Is this placement available only for Promoted Tweets ?


You’ve got to use the GET targeting_criteria/locations endpoint and get the country’s targeting_value. For example, for the US:

$ twurl -H "/2/targeting_criteria/locations?q=usa&location_type=COUNTRIES"
  "data": [
      "name": "United States",
      "country_code": "US",
      "location_type": "COUNTRIES",
      "targeting_value": "96683cc9126741d1",
      "targeting_type": "LOCATION"
      "name": "United States Minor Outlying Islands",
      "country_code": "UM",
      "location_type": "COUNTRIES",
      "targeting_value": "08fbcf4cbc4bc5b9",
      "targeting_type": "LOCATION"
  "request": {
    "params": {
      "location_type": "COUNTRIES",
      "q": "usa"
  "next_cursor": null

In this case, you’d use country=96683cc9126741d1 in the stats request:

$ twurl -X POST -H "/2/stats/jobs/accounts/18ce54d4x5t?start_time=2017-07-28&end_time=2017-08-28&entity=LINE_ITEM&entity_ids=5tddn&granularity=TOTAL&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER&segmentation_type=CITIES&country=96683cc9126741d1"

Hope this helps. Thanks!


Thanks a lot Juan. This is great help . !!!


:grinning: Glad to help!