Retrieving all possible metrics from Twitter Ads stats end point


#1

I would like to retrieve all the possible metrics from this stats endpoint:

https://dev.twitter.com/ads/reference/get/stats/accounts/%3Aaccount_id/promoted_tweets/%3Aid

The metrics parameter says that if it is left blank it will default to all possible metrics.

In the page that documents all the metrics, there is a contradicting statment:

"Metrics not returned by default must be requested using the metrics param."
https://dev.twitter.com/ads/analytics/metrics-and-segmentation-v0

When I try to call the stats endpoint without the metrics parameter, I get a list of about 50-60 metrics, out of the 115 metrics listed in the metrics page.

When I try to call the stats endpoint with a comma separated list of all 115 metrics listed in the metrics page, I get an error:

{‘message’: ‘Expected valid metric promoted_tweet_profile_retweets, promoted_tweet_tpn_favorites, promoted_tweet_tpn_retweets, promoted_tweet_profile_follows, promoted_tweet_search_qualified_impressions, promoted_tweet_search_favorites, promoted_tweet_search_follows, promoted_tweet_tpn_url_clicks, promoted_tweet_profile_clicks, promoted_tweet_search_engagements, promoted_tweet_search_replies, conversion_app_open, promoted_tweet_profile_favorites, promoted_tweet_timeline_clicks, promoted_tweet_search_retweets, promoted_tweet_timeline_engagement_rate, promoted_tweet_search_url_clicks, conversion_purchases, promoted_video_views_100, conversion_sign_ups, promoted_tweet_search_clicks, promoted_video_starts, mobile_conversion_installs, mobile_conversion_purchases, mobile_conversion_sign_ups, mobile_conversion_re_engages, mobile_conversion_logins, mobile_conversion_updates, mobile_conversion_tutorial_completes, mobile_conversion_reservations, mobile_conversion_add_to_cart, mobile_conversion_add_to_wishlist, mobile_conversion_checkout_initiated, mobile_conversion_searches, mobile_conversion_level_achieved, mobile_conversion_achievement_unlocked, mobile_conversion_content_views, mobile_conversion_shares, mobile_conversion_invites, mobile_conversion_added_payment_infos, mobile_conversion_spent_credits, mobile_conversion_rated, mobile_conversion_sale_amount_local_micro, mobile_conversion_order_quantity, mobile_lifetime_value_conversion_breakdown, mobile_lifetime_value_conversion_sale_amount_local_micro_breakdown, mobile_lifetime_value_conversion_order_quantity_breakdown, billed_charge_local_micro, promoted_tweet_search_impressions, promoted_tweet_search_engagement_rate, promoted_video_replays, promoted_tweet_timeline_qualified_impressions, promoted_tweet_tpn_engagements, promoted_tweet_profile_qualified_impressions, promoted_video_views_25, conversion_key_page_views, promoted_video_views_50, promoted_tweet_timeline_retweets, promoted_tweet_tpn_media_views, promoted_video_total_views, promoted_tweet_profile_impressions, promoted_tweet_app_open_attempts, promoted_tweet_profile_engagements, promoted_tweet_search_media_views, promoted_tweet_profile_media_views, promoted_tweet_app_install_attempts, promoted_tweet_tpn_impressions, promoted_tweet_tpn_engagement_rate, conversion_site_visits, promoted_video_cta_clicks, promoted_tweet_tpn_replies, promoted_tweet_timeline_favorites, promoted_tweet_tpn_card_engagements, promoted_tweet_profile_replies, promoted_tweet_timeline_replies, promoted_tweet_timeline_follows, promoted_tweet_timeline_engagements, conversion_downloads, conversion_sale_amount, promoted_tweet_search_card_engagements, promoted_tweet_timeline_url_clicks, promoted_tweet_profile_engagement_rate, promoted_tweet_tpn_clicks, conversion_order_quantity, promoted_tweet_profile_card_engagements, promoted_tweet_timeline_impressions, promoted_tweet_tpn_follows, conversion_custom, promoted_tweet_tpn_qualified_impressions, promoted_video_views_75, promoted_tweet_profile_url_clicks, promoted_tweet_timeline_card_engagements, promoted_tweet_timeline_media_views, got “promoted_account_follows” for metrics’, ‘code’: ‘INVALID_PARAMETER’, ‘parameter’: ‘metrics’}

Then when I try to call the stats endpoint with the list of metrics from that error message I get an error that contradicts itself. It says that the mobile_conversion_purchases metric is not an available metric, and it lists all the available metrics, and in the list you can find “mobile_conversion_purchases”:

{‘message’: ‘Expected valid metric promoted_tweet_search_media_views, promoted_tweet_tpn_replies, promoted_tweet_profile_replies, promoted_tweet_tpn_follows, conversion_app_open, promoted_tweet_search_retweets, conversion_sign_ups, promoted_tweet_tpn_url_clicks, promoted_tweet_search_replies, promoted_tweet_profile_engagements, conversion_sale_amount, promoted_tweet_timeline_clicks, mobile_conversion_installs, mobile_conversion_purchases, mobile_conversion_sign_ups, mobile_conversion_re_engages, mobile_conversion_logins, mobile_conversion_updates, mobile_conversion_tutorial_completes, mobile_conversion_reservations, mobile_conversion_add_to_cart, mobile_conversion_add_to_wishlist, mobile_conversion_checkout_initiated, mobile_conversion_searches, mobile_conversion_level_achieved, mobile_conversion_achievement_unlocked, mobile_conversion_content_views, mobile_conversion_shares, mobile_conversion_invites, mobile_conversion_added_payment_infos, mobile_conversion_spent_credits, mobile_conversion_rated, mobile_conversion_sale_amount_local_micro, mobile_conversion_order_quantity, mobile_lifetime_value_conversion_breakdown, mobile_lifetime_value_conversion_sale_amount_local_micro_breakdown, mobile_lifetime_value_conversion_order_quantity_breakdown, billed_charge_local_micro, promoted_tweet_tpn_impressions, promoted_tweet_tpn_qualified_impressions, promoted_tweet_profile_media_views, conversion_site_visits, promoted_tweet_timeline_card_engagements, promoted_tweet_search_clicks, promoted_tweet_app_install_attempts, promoted_video_views_100, promoted_video_starts, promoted_tweet_search_card_engagements, promoted_tweet_profile_follows, promoted_video_views_75, promoted_video_views_25, conversion_custom, promoted_tweet_search_engagement_rate, promoted_tweet_profile_card_engagements, promoted_tweet_tpn_engagements, promoted_tweet_search_url_clicks, conversion_key_page_views, promoted_tweet_profile_impressions, promoted_video_views_50, promoted_tweet_timeline_impressions, promoted_tweet_profile_qualified_impressions, promoted_tweet_tpn_favorites, promoted_video_total_views, promoted_tweet_timeline_media_views, conversion_order_quantity, promoted_tweet_search_engagements, promoted_tweet_app_open_attempts, promoted_tweet_search_impressions, promoted_tweet_tpn_card_engagements, promoted_tweet_search_qualified_impressions, promoted_tweet_profile_url_clicks, promoted_video_cta_clicks, promoted_tweet_timeline_favorites, promoted_tweet_timeline_replies, promoted_tweet_tpn_retweets, promoted_tweet_timeline_retweets, promoted_tweet_timeline_url_clicks, promoted_tweet_timeline_engagement_rate, promoted_tweet_tpn_media_views, promoted_tweet_search_favorites, promoted_tweet_profile_engagement_rate, promoted_tweet_timeline_qualified_impressions, conversion_purchases, promoted_tweet_timeline_follows, promoted_video_replays, conversion_downloads, promoted_tweet_search_follows, promoted_tweet_tpn_engagement_rate, promoted_tweet_profile_favorites, promoted_tweet_timeline_engagements, promoted_tweet_profile_clicks, promoted_tweet_profile_retweets, promoted_tweet_tpn_clicks, got " mobile_conversion_purchases" for metrics’, ‘code’: ‘INVALID_PARAMETER’, ‘parameter’: ‘metrics’}

So is there a way in which I can get all the available metrics?


#2

Hi @m_taleski! I believe this is because not all metrics are applicable, and thus available, to all campaign objectives. For example, promoted_account_follows is only applicable to FOLLOWERS campaigns (and only retrievable at the line item level…) - what is the objective of the promoted ad’s campaign you’re trying to fetch the data for?


#3

@majoritasdev, thanks for your response.

I am not really taking into consideration the campaign objective.

I am trying to fetch all available data for a particular account in a particular time frame. So that means all accounts, all campaigns, all promoted tweets and all the metrics available.

I am aware that some tweets will have one group of metrics, and other tweets will have another group of metrics, but I am handling them, and producing a combined data set.

I just managed to run this properly and get a result. The value that I have set in metrics is:

mobile_conversion_installs,mobile_conversion_purchases,mobile_conversion_sign_ups,mobile_conversion_re_engages,mobile_conversion_logins,mobile_conversion_updates,mobile_conversion_tutorial_completes,mobile_conversion_reservations,mobile_conversion_add_to_cart,mobile_conversion_add_to_wishlist,mobile_conversion_checkout_initiated,mobile_conversion_searches,mobile_conversion_level_achieved,mobile_conversion_achievement_unlocked,mobile_conversion_content_views,mobile_conversion_shares,mobile_conversion_invites,mobile_conversion_added_payment_infos,mobile_conversion_spent_credits,mobile_conversion_rated,mobile_conversion_sale_amount_local_micro,mobile_conversion_order_quantity,mobile_lifetime_value_conversion_breakdown,mobile_lifetime_value_conversion_sale_amount_local_micro_breakdown,mobile_lifetime_value_conversion_order_quantity_breakdown,billed_charge_local_micro,promoted_video_cta_clicks,promoted_tweet_tpn_card_engagements,conversion_custom,promoted_tweet_search_favorites,promoted_tweet_app_open_attempts,promoted_tweet_profile_media_views,promoted_tweet_app_install_attempts,promoted_video_views_100,promoted_tweet_search_media_views,promoted_tweet_timeline_retweets,promoted_tweet_timeline_card_engagements,promoted_tweet_profile_favorites,promoted_tweet_profile_card_engagements,conversion_purchases,promoted_video_starts,promoted_video_views_25,promoted_tweet_search_replies,promoted_tweet_profile_clicks,promoted_tweet_tpn_clicks,promoted_tweet_profile_qualified_impressions,promoted_tweet_tpn_retweets,promoted_tweet_timeline_url_clicks,promoted_video_views_50,promoted_tweet_tpn_replies,promoted_tweet_search_clicks,promoted_tweet_tpn_favorites,promoted_tweet_profile_engagements,conversion_order_quantity,promoted_tweet_tpn_engagements,promoted_tweet_tpn_url_clicks,promoted_tweet_search_url_clicks,promoted_tweet_search_impressions,promoted_tweet_profile_impressions,promoted_tweet_timeline_engagement_rate,conversion_sign_ups,conversion_key_page_views,promoted_video_views_75,promoted_tweet_tpn_qualified_impressions,promoted_tweet_tpn_impressions,promoted_tweet_profile_url_clicks,promoted_tweet_search_engagement_rate,promoted_tweet_search_follows,promoted_tweet_timeline_impressions,promoted_tweet_profile_engagement_rate,promoted_tweet_timeline_favorites,promoted_tweet_tpn_engagement_rate,conversion_site_visits,promoted_tweet_timeline_media_views,promoted_tweet_tpn_media_views,promoted_tweet_search_qualified_impressions,promoted_tweet_tpn_follows,promoted_tweet_search_engagements,promoted_tweet_profile_retweets,conversion_app_open,promoted_tweet_profile_follows,promoted_video_replays,promoted_tweet_timeline_qualified_impressions,promoted_video_total_views,promoted_tweet_search_card_engagements,promoted_tweet_timeline_replies,promoted_tweet_timeline_follows,conversion_sale_amount,promoted_tweet_search_retweets,conversion_downloads,promoted_tweet_profile_replies,promoted_tweet_timeline_engagements,promoted_tweet_timeline_clicks

I only had to remove the spaces between the values and I got back all the metrics.

But this still contradicts with the endpoint documentation, that says “by default it will return all possible metrics”.

In my case if I leave it blank I get about 50 metrics. If I list all the metrics from above I get them all.

For example the Promoted Video Starts metric gets returned with values only when I specifically list it. If I don’t list it it does not have values.

So is there a general way of retrieving all possible metrics that have values?


#4

I don’t think so, you should request specifically those metrics that you want. As far as I know, Twitter’s wish is to request only the metrics that you need - I guess this has not changed in Ads API v1. So I think the error is where the docs say that if you request no metrics, all of them will be given by default.

In the list you posted in your last post I see you removed promoted_account_follows, that’s why you don’t get any errors. What I’m saying is that you should take into consideration the ad’s objective when requesting the analytics data, so you can request only the mtrics that are applicable to that objective. But if you say that you are handling them, and producing a combined data set, maybe this is what you are doing…


#5

Hi @m_taleski

I think that is not the best option, you’re going to exhaust your token-cost limits!


#6

Is there a mapping between ad’s objective and metrics applicable for each objective, so I can automate this?


#7

Yes: https://dev.twitter.com/ads/analytics/metrics-derived
But please note that I have not yet revised the v1 of the Ads API, and I don’t know if this is still aplicable in v1. But if you’re using v0 of the API then this is for you. :slight_smile:


#8

@majoritasdev, thanks for the info.

but this is again a bit confusing, because the derived metrics page does not list all the possible metrics. For example only one of the mobile_ metrics is mentioned ( mobile_conversion_installs ), under section APP_INSTALLS, APP_ENGAGEMENTS.

Does that mean that I should not request for the other mobile_ metrics.

This list seems incomplete, in the way that it does not list all the available metrics per objective.


#9

I think that that page lists only the metrics that are used for calculation of the data displayed in the Ads UI (if you want to compare what you show in your platform to what it is shown in the Ads UI).