Ads API - Pulling Device, location, etc Info

location
ads

#1

Hi,

From the API it doesn’t seem like it’s possible to get device, location, gender, etc data from clicks or impressions of a campaign run.

But this info is available on the Ad Manager ‘Audience’ screen in the Web app.

Is it possible to get from the API?

Thanks and regards,
Justin


#2

@EaglePtPartners: Please see this documentation for information on how to do this using the Ads API. Note that you must use the POST /1/stats/jobs/accounts/:account_id for this. Thanks.


#3

Thanks so much for this!

I’m running the ‘POST jobs’ API against a campaign that ran in the past but it’s returning an empty response - for both the request & response data. But I’m getting a 200 response code. Any ideas?

I’m using twurl for this

{
  "request": {
    "params": {}
  },
  "data_type": "job",
  "next_cursor": null,
  "data": []
}

#4

FYI - twurl command we’re using:

twurl -t -H https://ads-api.twitter.com “/1/stats/jobs/accounts/18ce54h6gph?entity=LINE_ITEM&entity_ids=89jlk&start_time=2017-03-28T00:00:00Z&end_time=2017-03-30T00:00:00Z&granularity=TOTAL&placement=ALL_ON_TWITTER&metric_groups=ENGAGEMENT” | jq

The same details work fine when getting engagement data:

twurl -t -H https://ads-api.twitter.com “/1/stats/accounts/18ce54h6gph?start_time=2017-03-28T00:00:00Z&end_time=2017-03-30T00:00:00Z&granularity=TOTAL&entity=LINE_ITEM&entity_ids=89jlk&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER” | jq


#5

Thanks for providing these example requests, @EaglePtPartners. We’ll take a look and get back to you.


#6

@EaglePtPartners: We’ve taken a closer look at these requests and they’re actually the identical—they use the same param values. Could you please clarify which request is causing problems?

In any case, looking at the response output, we can tell this came from a request to the GET /1/stats/jobs/accounts/:account_id endpoint—see "data_type": "job".

An example POST /1/stats/jobs/accounts/:account_id response (after going through the async flow, including downloading .gz file) looks like this (see "data_type": "stats"):

$ twurl -X POST -H ads-api.twitter.com "/1/stats/jobs/accounts/18ce54h6gph?entity=LINE_ITEM&entity_ids=89jlk&start_time=2017-03-28T00:00:00Z&end_time=2017-03-30T00:00:00Z&granularity=TOTAL&placement=ALL_ON_TWITTER&metric_groups=ENGAGEMENT"
{
  "data_type": "stats",
  "time_series_length": 1,
  "data": [
    {
      "id": "89jlk",
      "id_data": [
        {
          "segment": null,
          "metrics": {
            "impressions": [
              1011
            ],
            "tweets_send": null,
            "qualified_impressions": null,
            "follows": null,
            "app_clicks": null,
            "retweets": null,
            "likes": null,
            "engagements": [
              17
            ],
            "clicks": [
              17
            ],
            "card_engagements": null,
            "replies": null,
            "url_clicks": [
              6
            ],
            "carousel_swipes": null
          }
        }
      ]
    }
  ],
  "request": {
    "params": {
      "start_time": "2017-03-28T00:00:00Z",
      "segmentation_type": null,
      "entity_ids": [
        "89jlk"
      ],
      "end_time": "2017-03-30T00:00:00Z",
      "country": null,
      "placement": "ALL_ON_TWITTER",
      "granularity": "TOTAL",
      "entity": "LINE_ITEM",
      "platform": null,
      "metric_groups": [
        "ENGAGEMENT"
      ]
    }
  }
}

Hope this helps!


#7

Thanks @juanshishido!

It was the missing POST that was causing the problem as you said.

Got it all working now. Thanks!

One question - when pulling device data, we need to pass in a ‘platform’ parameter. Is there a list of values documented we can have here? I’ve tried with a few but getting nothing back (iOS, Android).

Thanks,
Justin


#8

Glad to hear it worked out, @EaglePtPartners!

Please take a look at our Metrics and Segmentation documentation for more information on how to pull PLATFORMS or DEVICES data. Thanks!


#9

Thanks - but the info on that page doesn’t give values to pass in as the ‘platform’ parameter, unfortunately.

Any other page documenting possible values here?


#10

@EaglePtPartners: Please see this post.