Instagram Graph API Insights - Reach between two dates - facebook-graph-api

In Instagram, the reach metric is a de-duplicated data source. In other words, the sum of 7 days worth of data does not necessarily equal the value for that week. This is similar to the Facebook Marketing reach metric.
I'd like to support this scenario: given two dates, give me the reach between those two dates.
In the FB Marketing API this is easily achieved using the since and until parameters to define the date boundaries, and then using a time_increment of all_days to retrieve the reach summed up across all those days.
For example, using the FB Marketing API Docs here is a FB Marketing url that requests a week's worth of data summed up:
{adaccount_id}/insights?metric=reach&since=2018-02-05&until=2018-02-11&time_increment=all_days
In the Instagram Graph API I can define a since and until parameter to define the date boundaries, but there is no parameter like time_increment.
Using the Instagram Graph API Docs, here is a url that requests a week's worth of data split up by day:
{instagram_business_account_id}/insights?metric=reach&period=day&since=1517788800&until=1518307200
Is there any way to change that around to get the summed up reach between two dates? I had hoped for a period option of all_days similar to the FB Marketing API's time_increment parameter but that doesn't exist.

Related

Fetching Facebook Ad spends grouped by campaign names

I wanted to fetch the daily ad spends in Facebook based on campaigns separately, ie, for each campaign with its spend.
I have tried with API call, but that gives state wise classification. How do I group based on campaign names?
"https://graph.facebook.com/v14.0/act_xxxxxx/insights?" + encodeURI("level=ad&fields=spend&access_token=FB_ACCESS_TOKEN&breakdowns=region,country&time_range={'since':'2022-08-09','until':'2022-08-09'}&filtering=[{\"field\":\"country\",\"operator\":\"CONTAIN\",\"value\":\"US\"}]&limit=100")
Campaigns and adsets has an insights field where you can read performance and spending metrics.
Get insights from campaigns endpoint
https://graph.facebook.com/v14.0/act_xxx/campaigns?fields=name,insights{spend}
you can use date filters with you calls to get lifetime spending.
you can also get spending from campaign adset insights field.
Check the official documentation
https://developers.facebook.com/docs/marketing-api/reference/ad-campaign/insights

How to build events aggregation service for high load system with DynamoDB

I'm working on an Ad-tech system which serves millions of users.
Basically users (non anonymous users) can see different Ads that are being created by the marketing team.
Our marketing team want to be able to set some Frequency caps on those Ads (among other targeting rules they already have)
For example:
"We should not show this ad for a user if he already seen/click this ad more than X times in the last Y days"
Also ads can be grouped to campaigns, so rules like that are also possibile:
"We should not show this for a user if he viewed more than X times ads in this campaign in the last Y days".
Also our marketing might wanna know how many people viewed/click a specific add in the last Y days.
We have roughly 200K RPM and our responses should be very fast.
The smallest unit of time for our queries is one day and it will not change.
Few questions and thoughts:
Is DynamoDB a good fit?
I thought about creating a table for each event type (Click/View/Close..)
What is the best way to configure the primary key?
I thought about settings the primary key as the user id and the sort key as a combination of the ad id and the current day {dd/mm/yyyy}
I thought about use "ADD" operation to increase the counter when a user click/view/.. an Ad in a specific date. are they expensive operations? do I have an alternative?
What is the best way I can use to also be able to query per ad and campaigns as well (for example: "all users views for all ads in campaign" or "get all ad views in the last 40 days) ) ?
What other considerations should I take in mind?
Thanks a lot

Can the Facebook Marketing API return a list of objects that represent each individual click on an ad, including the FBCLID and spend for each click?

So far I've been able to get an overview of the total number of clicks during a specified time period using the Insights API:
{"impressions":"5547","spend":"160.53","clicks":"206","date_start":"2022-06-08","date_stop":"2022-06-08"}
What I would like instead is a list of objects that represent each individual click during that period, with fields like "fbclid", "date", "spend", etc:
{"fbclid":"jg4k0tkladskds08kds","spend":"0.75", "date":"2022-06-08 12:24:15"}
{"fbclid":"098okjfesdjflsdjffd","spend":"0.72", "date":"2022-06-08 18:36:02"}
{"fbclid":"04538hjfldkjlkdjfdfsdf","spend":"0.67", "date":"2022-06-08 21:12:12"}
etc...
Is this possible with either the Insights API or something else within the Marketing API? I'm using the Facebook Business SDK for PHP in case that's relevant. Thanks!

Number of Visitors by Hour

Is there a way to obtain from the Google Map API, the number of visitors to a place by hour of the year? I saw that I could get information like reviews and price level for a place, but not the number of visitors per hour. Essentially, I want to get the detailed data behind the Popular Times graph shown in Google Maps

Google Finance API Time Period

I am using a C# class to get the prices of a given stock from Google Finance.
The communication between the class and the Web Service is working well.
I am using the following url:
http://www.google.com/finance/historical?output=csv&q=BBAS3
The problem is that the returned prices are only from about 1 year ago.
I need to get all the available prices records.
If I search for stock ticker "BBAS3" in the Google webpage, it shows me a graph that goes until 2003.
As far I could find, there is no official documentation about the API.
I found some more info in this site:
Google's Undocumented Finance API
As it shows, I can use the following parameter:
p - Period. (A number followed by a "d" or "Y", eg. Days or years. Ex: 40Y = 40 years.)
Then I tried (&p=5Y):
http://www.google.com/finance/historical?output=csv&p=5Y&q=BBAS3
But the result was the same.
Does anyone knows another way to achieve what I need?
Google is changed Now.
I've been playing around with the undocumented Google Finance API. It provides intra-day data for the past 10 days and day-granularity data going back for years. Handy!
There are lots of web pages that attempt to describe how this thing works. I've pulled together a bunch of data from them, as well as a few of my own observations. You can watch this thing in action by popping open FireBug while messing about on with the google finance chart. It will make AJAX requests to this API.
Here's an example URL to pull all historical data for GOOG at daily granularity:
http://www.google.com/finance/getprices?q=GOOG&x=NASD&i=86400&p=40Y&f=d,c,v,k,o,h,l&df=cpct&auto=0&ei=Ef6XUYDfCqSTiAKEMg
Visit this Documentation
As You Search is Available at
https://www.google.com/finance/getprices?q=BBAS3&x=BVMF