Hi!
We are using Ads API to request data from ads and videos in different requests. But in both cases we see that there are some metrics which are similar to the platform but others aren’t. We tried with the Synchronous and Asynchronous endpoints and we got the same results.
Here is an example of a request using the Synchronous Analytics Endpoint:
‘’’
Synchronous Analytics
‘’’
url = Synchronous Analytics URL
r = oauth_user.get(url, params={‘account_id’: 'account_id,
‘end_time’: ‘2021-12-31T00:00:00Z’,
‘entity’: ‘LINE_ITEM’,
‘entity_ids’: ‘,’.join(campaign_ids),
‘granularity’: ‘TOTAL’,
‘metric_groups’: ‘ENGAGEMENT,BILLING’,
‘placement’: ‘ALL_ON_TWITTER’,
‘start_time’: ‘2021-12-30T00:00:00Z’}).json()
print(json.dumps(r, indent=2))
Could you help to solve this problem please?
Thanks in advance.
Statistics differences between the API and UI are usually caused by a few different things:
- Your application will need to make requests for both placements,
ALL_ON_TWITTER and PUBLISHER_NETWORK , separately and sum up the results to match the UI,
- date ranges in the UI are inclusive while the
end_time is exclusive in the API, and
- the API will default to midnight in the accounts local timezone, if not specified
If these aren’t causing the discrepancy, please provide the Account ID, Entity IDs, and any campaign information in the UI that isn’t matching.
We have tried it considering the differences you mentionated but we got the same results as before because when we make a request with the placement PUBLISHER_NETWORK, all metrics are NULL.
Additionally, when we set the end_time in the following day that we are interested in, the metrics are higher to those of the platform. We tried this because you said that are exclusive.
This is the information you asked for:
-
Account ID —> 18ce55f0qr3
-
Entity IDs —> [‘1r2pq’, ‘1r56b’, ‘1rmjw’, ‘1rmjx’, ‘1rt3p’, ‘1rt3q’, ‘1rwn3’, ‘1rwn5’, ‘1rx2p’, ‘1rx2t’, ‘1rx2u’, ‘1rx2y’, ‘1s0ni’, ‘1s0nj’, ‘1s0nk’, ‘1s0nm’, ‘1s0nn’, ‘1s0no’, ‘1s0np’, ‘1s6ey’, ‘1s6ez’, ‘1s6f0’, ‘1s6f1’, ‘1s6f2’, ‘1s6f3’, ‘1s6f4’, ‘1sbcy’, ‘1sbcz’, ‘1sbd0’, ‘1sbd7’, ‘1sbd8’]
This a screenshot with the UI in the platform:
If you need more information, let us know.
Thanks in advance.
The screenshot above appears to show the Funding Instrument-level view of the account. Digging into Campaign 27240879 g7v73 and Line Item 35232723 kz5qr, we can see 329,471 impressions. The following fields will return the same impressions:
"request": {
"params": {
"start_time": "2021-12-19T23:00:00Z",
"segmentation_type": null,
"entity_ids": [
"kz5qr",
"g84w6"
],
"end_time": "2021-12-26T23:00:00Z",
"country": null,
"placement": "ALL_ON_TWITTER",
"granularity": "TOTAL",
"entity": "LINE_ITEM",
"platform": null,
"metric_groups": [
"ENGAGEMENT",
"BILLING",
"VIDEO",
"MEDIA",
"WEB_CONVERSION"
]
}
}
Note that the request is using T23:00:00Z to get the correct time zone. Could you update your requests to use this time zone and verify the numbers are matching the Twitter Ads Manager stats?
If you are still seeing an issue, could you provide a single entity ID, the API request to fetch the data, and a screenshot showing the discrepancy.
Sorry for replying so late, I’ve changed the time in the request as you commented and now the data coincides with that of the platform. Thank you for your time and for help us.