Facebook Ads Api: Can you Get Timeseries of CPI in 15 minutes intervals? - facebook

I've just started playing with API's for the first time and my first attempt is with the facebook ads api. I'm looking through the documentation and can see how to pull all cost per action data. Right now I'm really interested in CPI (Cost Per Install) data for a specific campaign, ad set and ad in 15 minute intervals.
Does anyone know if this is even possible with the current API?

You can get reporting stats through the Ads Insights Api:
https://developers.facebook.com/docs/marketing-api/insights/v2.5
As you mentioned, you can get Cost Per Install data by requesting the cost_per_action_type field in your request.
For instance, a call to v2.5/<AD_SET_ID>/insights?fields=['cost_per_action_type']
Would have the cost of mobile app installs as part of the response
{
"data": [
{
"cost_per_action_type": [
{
"action_type": "mobile_app_install",
"value": ...
}
],
"date_start": ...,
"date_stop": ...
}
}
You can make api calls at your discretion as long as you're within the api rate limits: https://developers.facebook.com/docs/marketing-api/api-rate-limiting

Related

cloud whatsapp api limit conversations per month

I'm building a bot using WhatsApp Cloud API,
I'm looking for a way to limit the number of conversations per month per payment, for example, I have a budget of 200USD per month, if I reached it, it will not send more messages/conversations
I checked the API documentation and I didn't see anything about it.
There is no straight way but You can use Conversation Analytics API from WhatsApp Business Management API, to keep track of the total cost, which provides the cost of conversation as per provided granularity, following is the example of response,
{
"conversation_analytics": {
"data": [
{
"data_points": [
{
"start": 1643702400,
"end": 1646121600,
"conversation": 6250,
"phone_number": "1919XXXX58X",
"conversation_type": "REGULAR",
"conversation_direction": "BUSINESS_INITIATED",
"cost": 55.0204
},
...
]
}
]
}
}
It will give cost by groping conversation type, conversation direction, and business phone number,
Conversation Types:
FREE_ENTRY: Conversations originating from a free entry point.
FREE_TIER: Conversations within the monthly free tier.
REGULAR: Any conversations that did not originate from a free entry point or are above the monthly free tier allotment.
Conversation Direction:
business_initiated: Conversations initiated by the business.
user_initiated: Conversations initiated by an end user/customer.

Google Analytics Data API online users [duplicate]

I've recently added a Google Analytics GA4 tag to a website for the purpose of counting the currently active users. Before, I could see the number of real-time users right now (I think it had a one-minute delay, but I'm not sure).
But in the new GA4, I can only see the number corresponding to 30 minutes, which is not what I needed.
I've looked around and found an option to add a time dimension of 1 minute, but it was for the old google analytics, and it didn't seem right to me.
Not sure if it's needed to provide my code for this question, but if it's a must, then I'll add it.
Edit:
#Run a realtime report to get desired metrics.
def run_realtime_report(property_id):
#Runs a realtime report on a Google Analytics 4 property.
client = BetaAnalyticsDataClient()
#Run the request.
request = RunRealtimeReportRequest(
property=f"properties/{property_id}",
metrics=[Metric(name="activeUsers")],
)
#Parse the response.
response = client.run_realtime_report(request)
...
return activeUsers
#Run the realtime report function.
def run_sample():
global property_id
return run_realtime_report(property_id)
The number of users in the last 30 minutes in GA4 is similar to the "active users on site right now" in Universal Analytics (UA). However after about 5 minutes of inactivity, UA sometimes assesses users are no longer active on the site. This realtime report was generated with pageviews in the last 5 minutes:
After 5 minutes of inactivity, the active users on site goes to zero:
In GA4, you could recreate that calculation by specifying the minutesRange in your realtime report request. This page describes the minuteRange parameter. As a JSON request, this report will only count users who were active in the last 5 minutes:
{
"metrics": [
{
"name": "activeUsers"
}
],
"minuteRanges": [
{
"startMinutesAgo": 5,
"endMinutesAgo": 0
}
]
}
This request is different from GA4 realtime reporting which highlights the "users in last 30 minutes" as the primary realtime metric:

Real time (true real time) Google Analytics (GA4) - not the last 30 minutes [duplicate]

I've recently added a Google Analytics GA4 tag to a website for the purpose of counting the currently active users. Before, I could see the number of real-time users right now (I think it had a one-minute delay, but I'm not sure).
But in the new GA4, I can only see the number corresponding to 30 minutes, which is not what I needed.
I've looked around and found an option to add a time dimension of 1 minute, but it was for the old google analytics, and it didn't seem right to me.
Not sure if it's needed to provide my code for this question, but if it's a must, then I'll add it.
Edit:
#Run a realtime report to get desired metrics.
def run_realtime_report(property_id):
#Runs a realtime report on a Google Analytics 4 property.
client = BetaAnalyticsDataClient()
#Run the request.
request = RunRealtimeReportRequest(
property=f"properties/{property_id}",
metrics=[Metric(name="activeUsers")],
)
#Parse the response.
response = client.run_realtime_report(request)
...
return activeUsers
#Run the realtime report function.
def run_sample():
global property_id
return run_realtime_report(property_id)
The number of users in the last 30 minutes in GA4 is similar to the "active users on site right now" in Universal Analytics (UA). However after about 5 minutes of inactivity, UA sometimes assesses users are no longer active on the site. This realtime report was generated with pageviews in the last 5 minutes:
After 5 minutes of inactivity, the active users on site goes to zero:
In GA4, you could recreate that calculation by specifying the minutesRange in your realtime report request. This page describes the minuteRange parameter. As a JSON request, this report will only count users who were active in the last 5 minutes:
{
"metrics": [
{
"name": "activeUsers"
}
],
"minuteRanges": [
{
"startMinutesAgo": 5,
"endMinutesAgo": 0
}
]
}
This request is different from GA4 realtime reporting which highlights the "users in last 30 minutes" as the primary realtime metric:

Using DevOps Release REST API to determine time for release to complete

I'm using the DevOps REST API here:
https://learn.microsoft.com/en-us/rest/api/azure/devops/release/releases/list?view=azure-devops-rest-5.0
I have a specific release pipeline that I want to monitor for performance, I'd like to be able to query the pipeline to determine how long it's been taking to complete over the last n runs. then I can take that data and use it to determine if there's been any degradation in performance over time.
Is it possible to determine this info using the existing APIs? The API above seems to only talk about release start time, from playing around with the various options I haven't been able to get completion time from it.
It's not very easy to find but the following link returns the data you need:
https://vsrm.dev.azure.com/Utopia-Demo/Utopia/_apis/release/releases/1
"releaseDeployPhases": [
{
...
"deploymentJobs": [
{
"job": {
...
"dateStarted": "2019-01-23T14:40:59.603Z",
"dateEnded": "2019-01-23T14:42:49.863Z",
"startTime": "2019-01-23T14:40:59.603Z",
"finishTime": "2019-01-23T14:42:49.863Z",
...
},
Here is a start and end time on the job that you can use to calculate the job length.

Using post method to run an export takes too much time

I developed a Facebook application and I doing some offline analytics on the data from the dashboard.
I am using the Export API described here: https://developers.facebook.com/docs/analytics/export
According your explanation the time it should take is about 1-2 hours but, I did it every day in the past week and it took me about 2 days to download each one of the exports.
My application don't have big amount of data, each export is small.
Can you please help me understand what I am doing wrong or maybe you have problem with the export service?
I have Facebook page which I sell there sport clothes.
Each day I would like to see the following parameters from the traffic:
- Timezone of the device
- Device platform - iOS,Android,PC
- Event_log_time - timestamp at which the event is logged
I make everyday POST request to https://graph.facebook.com/v2.6/[Application FBID]/analytics_app_events_exports
with the following data:
access_token = {my access token}
start_ts = timestamp, begining of the day
end_ts = timestamp, end of the day
Then, after 5 hours I make get request to https://graph.facebook.com/V2.6/[Export FBID]?access_token={app access token}.
The response I get is:
"id": "##############",
"start_ts":"***",
"end_ts": "***",
"status": "SCHEDULED",
"column_names":[***],
"event_param_names":[{"event_name":[Event name]',"param_names":[Custom param names]}]
I have noticed that only after 2 Days the respone I get for the get request to https://graph.facebook.com/V2.6/[Export FBID]?access_token={app access token}
the status is COMPLETED.
My question is why it takes to long? according to your API it should take about 1-2 hours.