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?
- Objective
- Url
- Impression count
- Cost Per 1K impressions
- Link Clicks
- Link Click rate
- Cost per link Click
- 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.
- for url we usually get campaign edit page (when exporting data from ad portal)
- adsurl/campaign_form/accountID/campaign/XXXXXX/edit
- 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:
- for url we usually get campaign edit page (when exporting data from ad portal)
- adsurl/campaign_form/accountID/campaign/XXXXXX/edit
- 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