Get Campaign Insights
curl --request POST \
--url https://public.plai.io/meta/get_campaign_insights \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"userId": "<string>",
"campaignId": "<string>",
"startDate": "<string>",
"endDate": "<string>",
"currencySymbol": "<string>",
"clientCostAdjustment": {
"percentage": 123
}
}
'import requests
url = "https://public.plai.io/meta/get_campaign_insights"
payload = {
"userId": "<string>",
"campaignId": "<string>",
"startDate": "<string>",
"endDate": "<string>",
"currencySymbol": "<string>",
"clientCostAdjustment": { "percentage": 123 }
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
userId: '<string>',
campaignId: '<string>',
startDate: '<string>',
endDate: '<string>',
currencySymbol: '<string>',
clientCostAdjustment: {percentage: 123}
})
};
fetch('https://public.plai.io/meta/get_campaign_insights', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public.plai.io/meta/get_campaign_insights",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'userId' => '<string>',
'campaignId' => '<string>',
'startDate' => '<string>',
'endDate' => '<string>',
'currencySymbol' => '<string>',
'clientCostAdjustment' => [
'percentage' => 123
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public.plai.io/meta/get_campaign_insights"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"campaignId\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"currencySymbol\": \"<string>\",\n \"clientCostAdjustment\": {\n \"percentage\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://public.plai.io/meta/get_campaign_insights")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"<string>\",\n \"campaignId\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"currencySymbol\": \"<string>\",\n \"clientCostAdjustment\": {\n \"percentage\": 123\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.plai.io/meta/get_campaign_insights")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"userId\": \"<string>\",\n \"campaignId\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"currencySymbol\": \"<string>\",\n \"clientCostAdjustment\": {\n \"percentage\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"results": {
"success": true,
"insights": {
"name": "<string>",
"stats": {
"campaignName": "<string>",
"cpm": "<string>",
"reach": "<string>",
"cpc": "<string>",
"ctr": "<string>",
"clicks": "<string>",
"spend": "<string>",
"conversions": "<string>",
"cost_per_conversion": "<string>",
"conversion_rate_ranking": "<string>",
"quality_ranking": "<string>",
"date_start": "<string>",
"date_end": "<string>",
"leadCount": "<string>",
"cost_per_action_type": [
{}
],
"actions": [
{}
],
"videoAvgTimeWatched": "<string>",
"video30SecWatched": "<string>",
"videoNoOfPlays": "<string>",
"video25PercentWatched": "<string>",
"video50PercentWatched": "<string>",
"video75PercentWatched": "<string>",
"video95PercentWatched": "<string>",
"video100PercentWatched": "<string>",
"postSaves": "<string>",
"postShares": "<string>",
"postReactions": "<string>",
"postComments": "<string>",
"postLikes": "<string>",
"cpmPrevious": "<string>",
"cpmPercent": "<string>"
},
"adsets": {
"[adset_id]": {
"name": "<string>",
"stats": {
"campaignName": "<string>",
"cpm": "<string>",
"reach": "<string>",
"cpc": "<string>",
"ctr": "<string>",
"clicks": "<string>",
"spend": "<string>",
"conversions": "<string>",
"cost_per_conversion": "<string>",
"conversion_rate_ranking": "<string>",
"quality_ranking": "<string>",
"date_start": "<string>",
"date_end": "<string>",
"leadCount": "<string>",
"cost_per_action_type": [
{}
],
"actions": [
{}
],
"videoAvgTimeWatched": "<string>",
"video30SecWatched": "<string>",
"videoNoOfPlays": "<string>",
"video25PercentWatched": "<string>",
"video50PercentWatched": "<string>",
"video75PercentWatched": "<string>",
"video95PercentWatched": "<string>",
"video100PercentWatched": "<string>",
"postSaves": "<string>",
"postShares": "<string>",
"postReactions": "<string>",
"postComments": "<string>",
"postLikes": "<string>",
"cpmPrevious": "<string>",
"cpmPercent": "<string>"
},
"ads": {}
}
},
"error": "<string>"
}
}
}Campaign
Get Campaign Insights
This endpoint is used to fetch campaign insights for a specific campaign.
POST
/
meta
/
get_campaign_insights
Get Campaign Insights
curl --request POST \
--url https://public.plai.io/meta/get_campaign_insights \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"userId": "<string>",
"campaignId": "<string>",
"startDate": "<string>",
"endDate": "<string>",
"currencySymbol": "<string>",
"clientCostAdjustment": {
"percentage": 123
}
}
'import requests
url = "https://public.plai.io/meta/get_campaign_insights"
payload = {
"userId": "<string>",
"campaignId": "<string>",
"startDate": "<string>",
"endDate": "<string>",
"currencySymbol": "<string>",
"clientCostAdjustment": { "percentage": 123 }
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
userId: '<string>',
campaignId: '<string>',
startDate: '<string>',
endDate: '<string>',
currencySymbol: '<string>',
clientCostAdjustment: {percentage: 123}
})
};
fetch('https://public.plai.io/meta/get_campaign_insights', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public.plai.io/meta/get_campaign_insights",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'userId' => '<string>',
'campaignId' => '<string>',
'startDate' => '<string>',
'endDate' => '<string>',
'currencySymbol' => '<string>',
'clientCostAdjustment' => [
'percentage' => 123
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public.plai.io/meta/get_campaign_insights"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"campaignId\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"currencySymbol\": \"<string>\",\n \"clientCostAdjustment\": {\n \"percentage\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://public.plai.io/meta/get_campaign_insights")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"<string>\",\n \"campaignId\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"currencySymbol\": \"<string>\",\n \"clientCostAdjustment\": {\n \"percentage\": 123\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.plai.io/meta/get_campaign_insights")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"userId\": \"<string>\",\n \"campaignId\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"currencySymbol\": \"<string>\",\n \"clientCostAdjustment\": {\n \"percentage\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"results": {
"success": true,
"insights": {
"name": "<string>",
"stats": {
"campaignName": "<string>",
"cpm": "<string>",
"reach": "<string>",
"cpc": "<string>",
"ctr": "<string>",
"clicks": "<string>",
"spend": "<string>",
"conversions": "<string>",
"cost_per_conversion": "<string>",
"conversion_rate_ranking": "<string>",
"quality_ranking": "<string>",
"date_start": "<string>",
"date_end": "<string>",
"leadCount": "<string>",
"cost_per_action_type": [
{}
],
"actions": [
{}
],
"videoAvgTimeWatched": "<string>",
"video30SecWatched": "<string>",
"videoNoOfPlays": "<string>",
"video25PercentWatched": "<string>",
"video50PercentWatched": "<string>",
"video75PercentWatched": "<string>",
"video95PercentWatched": "<string>",
"video100PercentWatched": "<string>",
"postSaves": "<string>",
"postShares": "<string>",
"postReactions": "<string>",
"postComments": "<string>",
"postLikes": "<string>",
"cpmPrevious": "<string>",
"cpmPercent": "<string>"
},
"adsets": {
"[adset_id]": {
"name": "<string>",
"stats": {
"campaignName": "<string>",
"cpm": "<string>",
"reach": "<string>",
"cpc": "<string>",
"ctr": "<string>",
"clicks": "<string>",
"spend": "<string>",
"conversions": "<string>",
"cost_per_conversion": "<string>",
"conversion_rate_ranking": "<string>",
"quality_ranking": "<string>",
"date_start": "<string>",
"date_end": "<string>",
"leadCount": "<string>",
"cost_per_action_type": [
{}
],
"actions": [
{}
],
"videoAvgTimeWatched": "<string>",
"video30SecWatched": "<string>",
"videoNoOfPlays": "<string>",
"video25PercentWatched": "<string>",
"video50PercentWatched": "<string>",
"video75PercentWatched": "<string>",
"video95PercentWatched": "<string>",
"video100PercentWatched": "<string>",
"postSaves": "<string>",
"postShares": "<string>",
"postReactions": "<string>",
"postComments": "<string>",
"postLikes": "<string>",
"cpmPrevious": "<string>",
"cpmPercent": "<string>"
},
"ads": {}
}
},
"error": "<string>"
}
}
}Request Body
string
required
User ID, If not already created, make a user on create user
page first. If already created,
retrieve the user ID from get profile
page.
string
required
The unique identifier of the campaign
string
The start date for the insights period in YYYY-MM-DD format. If the start
date is not provided, insights will be generated for all time.
string
The end date for the insights period in YYYY-MM-DD format. If the end date
is not provided, insights will be generated for all time.
string
required
The currency symbol to be used for monetary values
object
required
Show Cost Adjustment Object
Show Cost Adjustment Object
number
required
The percentage adjustment to be applied to costs
Response
boolean
Indicates that the HTTP response was successful (status code 200 OK).
object
Show Results Object
Show Results Object
boolean
Indicates whether the specific operation or API action was
successful.
object
Show Insights Object
Show Insights Object
string
The name of the insights report or campaign.
object
Show Stats Object
Show Stats Object
string
The name of the associated campaign.
string
Cost per thousand impressions.
string
Total number of unique users who saw the ad.
string
Cost per click.
string
Click-through rate (percentage).
string
Total number of clicks.
string
Total amount spent on the campaign.
string
Number of conversions.
string
Cost per conversion.
string
Ranking of conversion rate compared to similar
campaigns.
string
Quality ranking of the ad.
string
Start date of the reporting period.
string
End date of the reporting period.
string
Number of leads generated.
array
Array of cost per action type metrics.
array
Array of actions taken.
string
Average time video was watched.
string
Number of times video was watched for at least 30
seconds.
string
Total number of video plays.
string
Number of times 25% of video was watched.
string
Number of times 50% of video was watched.
string
Number of times 75% of video was watched.
string
Number of times 95% of video was watched.
string
Number of times video was fully watched.
string
Number of times post was saved.
string
Number of times post was shared.
string
Number of post reactions.
string
Number of post comments.
string
Number of post likes.
string
Previous period’s cost per thousand impressions.
string
Percentage change in CPM from previous period.
object
Show Adsets Object
Show Adsets Object
object
Show Adset Object
Show Adset Object
string
Name of the adset.
object
Show Adset Stats Object
Show Adset Stats Object
string
The name of the associated campaign.
string
Cost per thousand impressions.
string
Total number of unique users who saw
the ad.
string
Cost per click.
string
Click-through rate (percentage).
string
Total number of clicks.
string
Total amount spent on the campaign.
string
Number of conversions.
string
Cost per conversion.
string
Ranking of conversion rate compared
to similar campaigns.
string
Quality ranking of the ad.
string
Start date of the reporting period.
string
End date of the reporting period.
string
Number of leads generated.
array
Array of cost per action type
metrics.
array
Array of actions taken.
string
Average time video was watched.
string
Number of times video was watched
for at least 30 seconds.
string
Total number of video plays.
string
Number of times 25% of video was
watched.
string
Number of times 50% of video was
watched.
string
Number of times 75% of video was
watched.
string
Number of times 95% of video was
watched.
string
Number of times video was fully
watched.
string
Number of times post was saved.
string
Number of times post was shared.
string
Number of post reactions.
string
Number of post comments.
string
Number of post likes.
string
Previous period’s cost per thousand
impressions.
string
Percentage change in CPM from
previous period.
object
Show Ads Object
Show Ads Object
Object containing individual ad
performance data.
string
Error string if something went wrong