How to filter facebook API Campaign data by veiculation date - facebook

As of now, my query is:
https://graph.facebook.com/v3.1/my_adact/campaigns?fields=name,insights{spend,reach,impressions,clicks},start_time,end_time&date_preset=this_month&limit=100
How should I make it so I can filter by campaigns that ran this month?}
Thanks!

To see campaign stats for every campaign that was active this month you can use the following query and the insights endpoint:
https://graph.facebook.com/v3.1/act_xxxxxx/insights?date_preset=this_month&level=campaign&fields=campaign_name,campaign_id,spend,impressions,reach,actions,clicks
This will return the insights as defined in the field parameter rolled up to the campaign level as defined by the level parameter and for this_month.

Related

How to retrieve stats for dynamic templates via Sendgrid API

I'm looking for help on how to retrieve stats for dynamic templates via SG API using curl.
Using https://api.sendgrid.com/v3/templates?generations=dynamic I've been able to get
specific template info but I can't seem to successfully use the dynamic template_id
and version id or subject id to pull stats for each email under the main template_id.
I get success returns for all stats using https://api.sendgrid.com/v3/stats?start_date=2022-05-01
but when I try to add template_id or any other param it's ignored by the API.
Any ideas? Thanks.
In the documentation for the global email statistics API the available query parameters that you can provide are:
limit
offset
aggregated_by - can be "day", "week" or "month"
start_date - as you used in your example
end_date
You cannot filter by the template, version or subject.

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}}}

How correctly make REST API request to get complete orders between a date range in Magento 2

I want to get complete orders between a date range using Magento 2 REST Api. So request looks like:
/rest/V1/orders?searchCriteria[filterGroups][0][filters][0][field]=status&searchCriteria[filterGroups][0][filters][0][value]=Complete&searchCriteria[filterGroups][0][filters][0][conditionType]=eq
Now I want get it in specific period. I found that Magento api has "from" and "to" fields but I always confused in searchCriteria filter index. Can anybody complete my request? Thanks
You will get complete orders between a date range by using the conditions from and to.
This API will get you the orders between the two dates:
http://<magento_host>/rest/V1/orders?
searchCriteria[filter_groups][0][filters][0][field]=created_at&
searchCriteria[filter_groups][0][filters][0][condition_type]=from&
searchCriteria[filter_groups][0][filters][0][value]=from_date&
searchCriteria[filter_groups][1][filters][0][field]=created_at&
searchCriteria[filter_groups][1][filters][0][condition_type]=to&
searchCriteria[filter_groups][1][filters][0][value]=to_date
Example:
http://<magento_host>/rest/V1/orders?
searchCriteria[filter_groups][0][filters][0][field]=created_at&
searchCriteria[filter_groups][0][filters][0][condition_type]=from&
searchCriteria[filter_groups][0][filters][0][value]=2016-07-01 00:00:00&
searchCriteria[filter_groups][1][filters][0][field]=created_at&
searchCriteria[filter_groups][1][filters][0][condition_type]=to&
searchCriteria[filter_groups][1][filters][0][value]=2018-07-01 00:00:00
The above API will get you the orders between a by using created_at timestamp.
For an example also see the Magento Docs.

Facebook Ads API query to pull the adgroup my campignId and the adstats that suprrort them at the same time

I am running the query below and it is returning all of the the adgroups associated with this campaign ID which is provided, I am wondering would it be possible for me to get the ad-statics using the same query for all of the adgroups provided. if so how would i go about doing this. Please take into account I want the data to return all of the data for the adgroups and the statistic for that adgroup
act_10188168/adgroups?end_time=2013-06-02&start_time=2013-06-01&campaign_ids=[60074688]
You need us the adgroupstats API with the list of ad ids received from the previous query.
https://graph.facebook.com/act_{ad_account_id}/adgroupstats?adgroup_ids=[JSON-encoded array of ad group IDs]

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.