Facebook Marketing API: Is it possible to filter insights by status - facebook

I am trying to filter adsets insights by adset status, but when I add a status filter, I get an empty dataset back:
curl "https://graph.facebook.com/v2.7/act_<redacted>/insights?fields=clicks,impressions,cpc,ctr,account_id&time_range%5Bsince%5D=2016-01-12&time_range%5Buntil%5D=2016-09-12&access_token=<redacted>&format=json&filtering=%5B%7B%22field%22:%22status%22,%22operator%22:%22EQUAL%22,%22value%22:%22ACTIVE%22%7D%5D&level=adset"
here is what filtering param looks like before it gets url-encoded:
[{"field":"status","operator":"EQUAL","value":"ACTIVE"}]
I have tried all valid values for status ACTIVE, PAUSED, DELETED, ARCHIVED to no avail.
When I remove filtering param - I see my data.
The question is:
Does anyone know if it is possible to filter by status, and if it is, what I am doing wrong?

It is possible. Using latest version as of March 2018.
You need to actually request all the ads that are ACTIVE and then provide insights as a 'nested' list of fields.
Replace 123456 with your ad account (but leave the 'act_' which is needed)
act_123456/ads?fields=effective_status,name,insights{total_action_value,total_actions,actions},adset_id,campaign_id&filtering=[{'field':'effective_status','operator':'IN','value':['ACTIVE']}]
This also works for /campaigns and /adsets
You can also do this (be sure to include &level=ad):
act_123456/insights?fields=ad_id,adset_id,campaign_name,action_values,campaign_id,total_action_value&level=ad&filtering=[{"field":"campaign.delivery_info","operator":"IN","value":["active"]}]

Filtering by insights isn't possible. At least in v2.7. To get insights for let's say ads I've decided to do the following:
1. Fetch ads that I need via /ads call. This allows me to filter by status.
2. Fetch insights for the same collection of ads and make sure that I ad id is included in the response.
3. Filter the second collection using the first one.

i m using this to filter campaigns with insights , working for me , start playing with it
'filtering'=>
array(
array(
"field"=>"campaign.effective_status",
"operator"=>"IN",
"value"=>$campaigncheckstatus,
),
),
$campaigncheckstatus = array("ACTIVE","PAUSED");
dont forget to json_encode $campaigncheckstatus if passed through url

Related

Shopify API: How to get id where is greater than

How can I get orders thru Shopify API where the id is greater than xxxxx?
Something like:
admin/api/2020-01/orders.json?id>=1900000000
or
admin/api/2020-01/orders.json?min_id=1900000000
I hope you understand what I mean.
If you read the documentation you see that orders have a created_at_min and created_at_max. Those values are what you use as your filter criteria for dates. If you need to work off of ID then you can try the since_id filter. In other words, give me all order since 123456. You get what I mean?

Facebook Graph API (v.3.1) Marketing API: use two paramaters with Campaign Insights

I'm trying to return campaign insights in the Facebook Marketing API and show the results aggregated for each day and broken down by country.
I'm trying
act_xxxx/?fields=campaigns{name,insights}&time_increment=1&breakdowns=country
but the country and time_increment paramaters don't seem to affect the results.
I've had success with EITHER time_increment of breakdowns if I don't use the ?fields paramater but then I'm not aggregating at the level I want and can still only use one paramater.
Can anyone suggest anything?
Thanks
James
Managed to figure this one out:
act_xxx/insights?fields=account_name,campaign_name,date_start,date_stop,spend,reach,impressions,cpc,inline_link_clicks,frequency,ctr,cost_per_inline_link_click,inline_link_click_ctr&breakdowns=country&time_increment=1&level=campaign
The key things I was missing were:
define the level of aggregation in the ?level paramater return the
Return insights edge before the ?fields paramater rather than through field
extension as I did in my example.
all you have to do is
act_xxxx?fields=campaigns{name,insights.time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country)}
This one fetches all campaigns name and insights between the date interval in day by day manner breaking down according to countries
you can use {} for subfields like
campaigns{ads{name,insights,adcreatives{image_url}}}
you can use . and () for parameters like; always make sure you use you use fields only after parameters like this order .(){}
campaigns.limit(1).time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country){ads{name,insights.time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country),adcreatives{image_url}}}

Filtering by action_target_id on Facebook Ads API

I am using the Facebook Ads API to try to filter out specific action target ids using the follwowing call:
(account-id)/reportstats?date_preset=yesterday&data_columns=["action_target_name","adgroup_id","adgroup_name","spend","actions","adgroup_objective"]&actions_group_by=["action_target_id", "action_destination"]&filters=[{"field": "action_target_id","type": "contains","value": 'insert id'}]
Every time I try to put in a specific ID, I get an empty data set back. Whenever I change the type to "not_contains", I get every piece of data returned. I've also tried the same with action_destination, but it keeps saying value needs to be numeric even though it a string.
It definitely seems like you can filter by action_target_id because when I tried to filter by something random, it told me that filter doesn't exist.
Can anyone help me please?
Unfortunately these values are nested under the actions fields of the results and filters only work on top level field values.

Retrieve information from SoundCloud developer console

I am trying to download the information about this user : https://soundcloud.com/beeldengeluid/,
and about this group : https://soundcloud.com/groups/het-geluid-van-nederland through your developer console here : http://developers.soundcloud.com/console. The user - "Beeld en Geluid" has 2,230 records, but all my attempts to download the information ended with just 50 records. Are there any user specific constraints or some user key that I should use to retrieve all the information in .xml format from the developer console?
Thank you in advance.
there is no 'constraints' or 'some user key' for that. but you can use pagination:
http://developers.soundcloud.com/docs/api/guide#pagination
Every call is limited by 50 results. Use the offset parameter in the querystring to get the next 50 results and so on:
example... "...&offset=0&..."
Next 50 results would be retrieved by using "...&offset=50&..."
Put this in a loop in your code to get the complete list.

Facebook insights domain_widget_likes -> lifetime don't return results?

I'm doing a query to get the total likes for a domain and I am using the following:
https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=xxxxxxxxx AND metric='domain_widget_likes' AND end_time=end_time_date('2011-08-27') AND period=period('lifetime')&access_token=xxxxxxxxx
I already claimed my domain, have the object id for my domain and installed an app to get access to insights and send the token.
But return nothing, if I try with period('day') the query works fine but I need all likes not only daily.
Anyone knows if it is a new rule on the insights data or is a bug?
Thanks a lot.
Are you able to use a wildcard % in the query like so (period LIKE period('%')):
https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=xxxxxxxxx AND metric='domain_widget_likes' AND end_time=end_time_date('2011-08-27') AND period LIKE period('%')&access_token=xxxxxxxxx
String Comparison Functions Reference has more info on query wildcards, etc.