Hi,

Currently we are pulling the Campaign metrics using the Twitter ads manager (aggregated on daily basis).We are working on pulling the same metrics via API but however we are unable to find any API endpoints to retrieve those metric attributes.

pastedImage.png

We are looking to find for the following metric attributes (aggregated on daily basis) using API.
can you let us know which API endpoint we should be using?

  1. Objective
  2. Url
  3. Impression count
  4. Cost Per 1K impressions
  5. Link Clicks
  6. Link Click rate
  7. Cost per link Click
  8. Video completions​

Not all data available via the Ads Manager UI is returned by the analytics endpoints. Many are documented here but some are calculated (cost per X or rate) and some are available via other APIs.

Objective is stored on the line item. It’s unclear what Url represents without seeing an example but may be on the Creative.

The other stats should be documented on the Metrics page or able to be calculated as shown in the derived metrics page.

I am also looking for this. Can you share python SDK for this with an example to refer?

Hi,

I am also looking for similar kind of data. Please let me know in case if you find any way to capture these details.

Thank you.

Thank you for the response, that was helpful.

  1. for url we usually get campaign edit page (when exporting data from ad portal)
    - adsurl/campaign_form/accountID/campaign/XXXXXX/edit
  2. Which API we can use to find out the campaign objective ?
    • when we exported data from ads portal we see the values are like Website clicks,Pre-roll views, Video views etc


Hi,
I ended up using the rest api as it was straight forward to get data.

Hi,
I ended up using the rest api as it was straight forward to get the data.

Thank you for your response. Can you please share sample rest API that you used.

i dont think we have api support to provide this info as of now. I verified and tried couple of ways but no luck. If anyone have a solution pls provide.

Hi,

I used the Synchronous Analytics | Docs | Twitter Developer Platform to get the details of those metrics and is works exactly as specified and matched what I downloaded from their portal.

When i tried below command in postman getting error
get https://ads-api.twitter.com/10/stats/accounts/<my_acc_id>?entity=LINE_ITEM&entity_ids=<line_item_id>&start_time=2021-12-01&end_time=2021-12-26&granularity=TOTAL&placement=ALL_ON_TWITTER&metric_groups=ENGAGEMENT

error message:

{
“errors”: [
{
“code”: “INVALID_PARAMETER”,
“message”: “Expected value in LIFE_TIME_VALUE_MOBILE_CONVERSION, ENGAGEMENT, MEDIA, WEB_CONVERSION, MOBILE_CONVERSION, VIDEO, BILLING, got "ENGAGEMENT " for metric_groups”,
“parameter”: “metric_groups”
}
],

Passed right value of metric_groups, but it is failing ( removed extra spaces but failing), any idea how can i get rid of this error.

Thanks,
Brahma

What metrics you’re looking for?

I am looking pretty much what you referred but above get statement example from Synchronous Analytics | Docs | Twitter Developer Platform , not sure you are referring samething or not.

If possible can you share your script, that will be great help.

Thanks,
Brahma

example: you can specify whatever mertric_groups you want AND granularity etc as fits your need.

get https://ads-api.twitter.com/10/stats/accounts/<my_acc_id>?entity=CAMPAIGN&entity_ids=xxx&start_time=xxx&end_time=xxxx&granularity=DAY&placement=PUBLISHER_NETWORK&metric_groups=BILLING,ENGAGEMENT,VIDEO,MEDIA,WEB_CONVERSION

Thank you for providing get statement but some how it is throwing an error for me.

my get statement:

get https://ads-api.twitter.com/10/stats/accounts/<my_acc_id>?entity=CAMPAIGN&entity_ids=<my_campaign_id>&start_time=2021-12-01&end_time=2021-12-26&granularity=DAY&placement=PUBLISHER_NETWORK&metric_groups=BILLING,ENGAGEMENT,VIDEO,MEDIA,WEB_CONVERSION

Error message/output :
{
“errors”: [
{
“code”: “INVALID_PARAMETER”,
“message”: “Expected value in LIFE_TIME_VALUE_MOBILE_CONVERSION, ENGAGEMENT, MEDIA, WEB_CONVERSION, MOBILE_CONVERSION, VIDEO, BILLING, got "WEB_CONVERSION " for metric_groups”,
“parameter”: “metric_groups”
}
],
“request”: {
“params”: {
“start_time”: “2021-12-01T08:00:00Z”,
“entity_ids”: [
“<campaign_id>”
],
“end_time”: “2021-12-26T08:00:00Z”,
“placement”: “PUBLISHER_NETWORK”,
“account_id”: “<acc_id>”,
“granularity”: “DAY”,
“entity”: “CAMPAIGN”
}
}
}

I don’t know why it is saying there is extra space at end of metric_groups param, same error getting for LINE_ITEM entity as well.

Can you through your thoughts on it.

It must be 7 day period for start and end times for synchronous end point.
start_time=2021-12-01&end_time=2021-12-07

Hi,
any updates on the following:

  1. for url we usually get campaign edit page (when exporting data from ad portal)
  • adsurl/campaign_form/accountID/campaign/XXXXXX/edit
  1. Which API we can use to find out the campaign objective ?
  • when we exported data from ads portal we see the values are like Website clicks,Pre-roll views, Video views etc


Thank you @sip_suser .

Now i am able to get data through API, but not all fields:

My code block:
for i in [‘6een’]: #‘97efj’, ‘fo9q3’, ‘foh51’, ‘fqi8k’]:
resource = ‘/10/stats/accounts/{account_id}/’.format(account_id=account.id)
params = {‘entity’: ‘LINE_ITEM’, # this is where promoted tweet ids will go
‘entity_ids’: i, # this is where promoted tweet ids will go
‘start_time’: ‘2022-01-01’,
‘end_time’: ‘2022-01-05’,
‘granularity’: ‘DAY’,
‘metric_groups’: [‘BILLING’,‘ENGAGEMENT’,‘VIDEO’,‘MEDIA’,‘WEB_CONVERSION’],
‘placement’: ‘PUBLISHER_NETWORK’}
response = Request(client, ‘get’, resource, params=params).perform()
print(response.body[‘data’])

Output:
[{‘id’: ‘6een’, ‘id_data’: [{‘segment’: None, ‘metrics’: {‘billed_engagements’: None, ‘billed_charge_local_micro’: None}}]}]

But through POSTMAN, i am seeing many of fields and corresponding values.

Am i missing anything or is it API limitation?

Thank you.

Thanks,
Brahma

are you using twitter python sdk or rest api?
because if you’re getting the data using postman, I assume you can see same if you use rest client rather than using twitter python sdk

yes i am using sdk. Can you share how to authenticate to twitter rest api?

Thanks,
Brahma