Incorrect error message?

analytics

#1

Getting the error message that billed_charge_local_micro is an invalid metric (“Expected valid metric…”) when requesting data from the stats/accounts/[account_id]/campaigns endpoint. This worked last week, but not anymore today.


#2

@Tianape could you give us an example request & response using twurl please?


#3
twurl -H ads-api.twitter.com "/0/stats/accounts/18ce53wse4d?granularity=DAY&start_time=2015-01-01&campaign_ids=18ce53wse4d&end_time=2015-08-27&metrics=billed_charge_local_micro,promoted_tweet_timeline_impressions" > ./testing/campaigns.json

Response outputted in the .json file:

{"errors":[{"code":"INVALID_PARAMETER","message":"Expected valid metric conversion_key_page_views, promoted_video_total_views, promoted_tweet_timeline_url_clicks, promoted_tweet_search_replies, conversion_purchases, promoted_tweet_profile_card_engagements, promoted_tweet_tpn_impressions, promoted_account_follow_rate, promoted_tweet_timeline_favorites, promoted_tweet_app_install_attempts, promoted_video_views_100, promoted_tweet_profile_follows, conversion_sign_ups, promoted_tweet_timeline_engagement_rate, promoted_account_profile_visits, conversion_downloads, promoted_video_cta_clicks, promoted_tweet_search_url_clicks, promoted_video_replays, promoted_account_follows, promoted_tweet_tpn_clicks, promoted_tweet_timeline_replies, promoted_tweet_profile_impressions, promoted_tweet_timeline_clicks, promoted_tweet_timeline_impressions, promoted_tweet_search_favorites, conversion_custom, promoted_tweet_search_follows, conversion_app_open, promoted_tweet_timeline_follows, promoted_tweet_search_engagements, promoted_tweet_search_impressions, promoted_tweet_profile_clicks, promoted_tweet_search_clicks, promoted_tweet_profile_url_clicks, promoted_tweet_search_engagement_rate, promoted_tweet_tpn_url_clicks, promoted_tweet_search_retweets, promoted_tweet_timeline_engagements, promoted_tweet_timeline_retweets, promoted_video_views_75, promoted_tweet_profile_engagements, conversion_site_visits, promoted_tweet_tpn_engagement_rate, promoted_tweet_tpn_follows, promoted_tweet_timeline_card_engagements, promoted_video_views_50, promoted_video_views_25, promoted_tweet_profile_engagement_rate, promoted_tweet_search_card_engagements, promoted_tweet_tpn_card_engagements, promoted_tweet_tpn_replies, conversion_order_quantity, promoted_tweet_app_open_attempts, promoted_tweet_profile_favorites, 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_engagements, billed_follows, conversion_sale_amount, promoted_account_impressions, promoted_tweet_profile_replies, promoted_tweet_tpn_favorites, promoted_tweet_tpn_retweets, promoted_tweet_profile_retweets, promoted_tweet_tpn_engagements, got \"billed_charge_local_micro\" for metrics","parameter":"metrics"}],"request":{"params":{"start_time":"2014-12-31T23:00:00Z","end_time":"2015-08-26T22:00:00Z","granularity":"DAY","account_id":"18ce53wse4d"}}}

Thanks @andrs :slight_smile:


#4

@Tianape you’re currently making that call against GET /stats/accounts which is not actually a billable object itself and the reason that metric is invalid here. If you change your request to use the GET /stats/accounts/:account_id/campaigns endpoint you’ll be able to make this call successfully.

twurl -H ads-api.twitter.com "/0/stats/accounts/18ce53wse4d/campaigns?granularity=DAY&start_time=2015-01-01&campaign_ids=18ce53wse4d&end_time=2015-08-27&metrics=billed_charge_local_micro,promoted_tweet_timeline_impressions" 

That being said, if you pull stats at the account or campaign level like you’re trying to do here you’ll likely run into rate limit issues much quicker. As our best practices for analytics states, you should only pull metrics at the line item or promoted tweet level with hourly granularity. You can persist that info in your own database and easily roll it up into account, campaign and funding instrument or day levels.


#5

Ah I see, thanks :slight_smile: I think this should be stated on the Metrics and Segmentation page then, as there’s a column Available in all endpoints unless noted here which is empty for the billed_charge_local_micro metric. :wink:

The problem with the best practices you mention is that you have to provide tweet or line item ids to fetch data from them. In most use cases we don’t know the promoted tweet or line item ids yet. Most of the time we only know an account ID and only sometimes we know some campaign ID(s) from the start. It would be a very welcome addition if you could filter by campaign when fetching statistics on line item and promoted tweet level so you don’t have to fetch everything when it’s not necessary.