I am trying to get the insights of an adset using. From the docs here, I understand that the field cost_per_action_type should contain the values for offsite_conversion. But, it doesn't return any offsite_conversion values.
This is request I've made:
2.8/<adset_id>/insights?fields=cpc,cpm,cost_per_action_type,cost_per_total_action,total_action_value,actions&action_attribution_windows=7d_view,28d_click
And this is the response:
{
"data": [
{
"cpc": "0.00452",
"cpm": "0.284469",
"cost_per_action_type": [
{
"action_type": "comment",
"value": "0.048382",
"7d_view": "37.98",
"28d_click": "0.048444"
},
{
"action_type": "post_reaction",
"value": "0.011615",
"7d_view": "0.575455",
"28d_click": "0.011854"
},
{
"action_type": "page_engagement",
"value": "0.005765",
"7d_view": "0.566866",
"28d_click": "0.005824"
},
{
"action_type": "post_engagement",
"value": "0.005776",
"7d_view": "0.566866",
"28d_click": "0.005835"
},
{
"action_type": "like",
"value": "3.165",
"28d_click": "3.165"
},
{
"action_type": "link_click",
"value": "0.015352",
"28d_click": "0.015352"
},
{
"action_type": "post",
"value": "0.808085",
"28d_click": "0.808085"
}
],
"cost_per_total_action": "0.005765",
"total_action_value": "0",
"actions": [
{
"action_type": "comment",
"value": "785",
"7d_view": "1",
"28d_click": "784"
},
{
"action_type": "post_reaction",
"value": "3270",
"7d_view": "66",
"28d_click": "3204"
},
{
"action_type": "page_engagement",
"value": "6588",
"7d_view": "67",
"28d_click": "6521"
},
{
"action_type": "post_engagement",
"value": "6576",
"7d_view": "67",
"28d_click": "6509"
},
{
"action_type": "like",
"value": "12",
"28d_click": "12"
},
{
"action_type": "link_click",
"value": "2474",
"28d_click": "2474"
},
{
"action_type": "post",
"value": "47",
"28d_click": "47"
}
],
"date_start": "2016-11-12",
"date_stop": "2016-12-11"
}
],
"paging": {
"cursors": {
"before": "MAZDZD",
"after": "MAZDZD"
}
}
}
I am very well familiar with the Facebook's Graph API but not much familiar with ads part. Please help!
Your query is correct. Have you confirmed that the campaign you're querying is in fact tracking an Offline Event Set, and that the Event Set has events from people to whom your campaign has delivered impressions recently?
Related
i'm running node-fhir-server-mongo(Asymmetrik github repo)..when i put resource using PUT method and it stores in mongodb...everything works fine...but the data is partially stored...when i try to access the data i stored in database it only shows few pieces only...
below code is the data i want to store..
{
"resourceType": "Patient",
"id": "example3",
"text": {
"status": "generated",
},
"identifier": [
{
"use": "usual",
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0203",
"code": "MR"
}
]
},
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345",
"period": {
"start": "2001-05-06"
},
"assigner": {
"display": "Acme Healthcare"
}
}
],
"active": true,
"name": [
{
"use": "official",
"family": "Chalmers",
"given": [
"Peter",
"James"
]
},
{
"use": "usual",
"given": [
"Jim"
]
},
{
"use": "maiden",
"family": "Windsor",
"given": [
"Peter",
"James"
],
"period": {
"end": "2002"
}
}
],
"telecom": [
{
"use": "home"
},
{
"system": "phone",
"value": "(03) 5555 6473",
"use": "work",
"rank": 1
},
{
"system": "phone",
"value": "(03) 3410 5613",
"use": "mobile",
"rank": 2
},
{
"system": "phone",
"value": "(03) 5555 8834",
"use": "old",
"period": {
"end": "2014"
}
}
],
"gender": "male",
"birthDate": "1974-12-25",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "1974-12-25T14:35:45-05:00"
}
]
},
"deceasedBoolean": false,
"address": [
{
"use": "home",
"type": "both",
"text": "534 Erewhon St PeasantVille, Rainbow, Vic 3999",
"line": [
"534 Erewhon St"
],
"city": "PleasantVille",
"district": "Rainbow",
"state": "Vic",
"postalCode": "3999",
"period": {
"start": "1974-12-25"
}
}
],
"contact": [
{
"relationship": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0131",
"code": "N"
}
]
}
],
"name": {
"family": "du Marché",
"_family": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/humanname-own-prefix",
"valueString": "VV"
}
]
},
"given": [
"Bénédicte"
]
},
"telecom": [
{
"system": "phone",
"value": "+33 (237) 998327"
}
],
"address": {
"use": "home",
"type": "both",
"line": [
"534 Erewhon St"
],
"city": "PleasantVille",
"district": "Rainbow",
"state": "Vic",
"postalCode": "3999",
"period": {
"start": "1974-12-25"
}
},
"gender": "female",
"period": {
"start": "2012"
}
}
],
"managingOrganization": {
"reference": "Organization/1"
} }
and the actual data is stored on the mongodb is....
_id: "example3" id: "example3" meta: Object versionId: "1" lastUpdated: "2022-06-28T08:44:44+00:00" resourceType: "Patient"
if anyone know the answer or how to solve please let me know....thanks in advance!
I have sample collection of data
[
{
data: [
{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55,
"batters": {
"batter": [
{
"id": "1001",
"type": "Regular"
},
{
"id": "1002",
"type": "Chocolate"
},
{
"id": "1003",
"type": "Blueberry"
},
{
"id": "1004",
"type": "Devil's Food"
}
]
},
"topping": [
{
"id": "5001",
"type": "None"
},
{
"id": "5002",
"type": "Glazed"
},
{
"id": "5005",
"type": "Sugar"
},
{
"id": "5007",
"type": "Powdered Sugar"
},
{
"id": "5006",
"type": "Chocolate with Sprinkles"
},
{
"id": "5003",
"type": "Chocolate"
},
{
"id": "5004",
"type": "Maple"
}
]
},
{
"id": "0002",
"type": "donut",
"name": "Raised",
"ppu": 0.55,
"batters": {
"batter": [
{
"id": "1001",
"type": "Regular"
}
]
},
"topping": [
{
"id": "5001",
"type": "None"
},
{
"id": "5002",
"type": "Glazed"
},
{
"id": "5005",
"type": "Sugar"
},
{
"id": "5003",
"type": "Chocolate"
},
{
"id": "5004",
"type": "Maple"
}
]
},
{
"id": "0003",
"type": "donut",
"name": "Old Fashioned",
"ppu": 0.55,
"batters": {
"batter": [
{
"id": "1001",
"type": "Regular"
},
{
"id": "1002",
"type": "Chocolate"
}
]
},
"topping": [
{
"id": "5001",
"type": "None"
},
{
"id": "5002",
"type": "Glazed"
},
{
"id": "5003",
"type": "Chocolate"
},
{
"id": "5004",
"type": "Maple"
}
]
}
]
}
]
and I need data only in this formate of a specific id.
[
{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55
}
]
aggregate
db.collection.aggregate({
"$unwind": "$data"
},
{
"$match": {
"data.id": "0001"
}
},
{
"$project": {
"_id": "$data.id",
"type": "$data.type",
"name": "$data.name",
"ppu": "$data.ppu"
}
})
mongoplayground
I try to filter some results data from mongodb with mongoose in javascript.
This is my json structure:
{
"name": "john",
"firstname": "doe",
"yearold": 22,
"recipes": [
{
"title": "cheesecake",
"data": [
{
"name": "egg",
"label": "Eggs for",
"value": 6,
"unit": "piece"
},
{
"name": "oil",
"label": "Specific oil",
"unit": "oz",
"value": 0.2
},
{
"name": "flour",
"label": "Wholemel flour",
"value": 450,
"unit": "gr"
}
]
},
{
"title": "cake",
"data": [
{
"name": "egg",
"label": "Eggs for",
"value": 6,
"unit": "piece"
},
{
"name": "flour",
"label": "Wholemel flour",
"value": 500,
"unit": "gr"
},
]
}
]
}
In some case i need to return json data with hiding some values. For example I have a list that specifies all the values to hide
hidekeys=["egg"];
and i would like to get this:
{
"name": "john",
"firstname": "doe",
"yearold": 22,
"recipes": [
{
"title": "cheesecake",
"data": [
{
"name": "egg",
"label": "Eggs for",
"value": #######,
"unit": "piece"
},
{
"name": "oil",
"label": "Specific oil",
"unit": "oz",
"value": 0.2
},
{
"name": "flour",
"label": "Wholemel flour",
"value": 450,
"unit": "gr"
}
]
},
{
"title": "cake",
"data": [
{
"name": "egg",
"label": "Eggs for",
"value": #######,
"unit": "piece"
},
{
"name": "flour",
"label": "Wholemel flour",
"value": 500,
"unit": "gr"
},
]
}
]
}
For each recipe i need to hide ingredient value if it is specified in hidekeys.
I tried something with $project and $cond but it doesnt works
Here's a quick way of how to achieve this using $map
const hidekeys = ["egg"];
db.collection.aggregate([
{
$addFields: {
recipes: {
$map: {
input: "$recipes",
as: "recipe",
in: {
$mergeObjects: [
"$$recipe",
{
data: {
$map: {
input: "$$recipe.data",
as: "datum",
in: {
"$mergeObjects": [
"$$datum",
{
$cond: [
{
"$setIsSubset": [
[
"$$datum.name"
],
hidekeys
]
},
{
value: "#####"
},
{
value: "$$datum.value"
}
]
}
]
}
}
}
}
]
}
}
}
}
}
])
Mongo Playground
I have a mongodb which I want to extract some specific data.
Here is my json:
{
"jobs" : [
{
"id": 554523,
"code": "1256-554523",
"name": "Banco de Talentos",
"status": "published",
"type": "vacancy_type_effective",
"publicationType": "external",
"numVacancies": 1,
"departmentId": 108141,
"departmentName": "FUTURAS OPORTUNIDADES",
"roleId": 169970,
"roleName": "BANCO DE TALENTOS",
"createdAt": "2020-10-30T12:23:48.572Z",
"updatedAt": "2020-12-30T23:21:30.403Z",
"branchId": null,
"branchName": null
},
{
"id": 616834,
"code": "1256-616834",
"name": "YYYYYY (o) YYYYY",
"status": "frozen",
"type": "vacancy_type_effective",
"publicationType": "external",
"numVacancies": 1,
"departmentId": 109190,
"departmentName": "TESTE TESTE",
"roleId": 165712,
"roleName": "SL - TESTE PL",
"createdAt": "2020-12-16T14:17:36.187Z",
"updatedAt": "2021-01-29T17:08:43.613Z",
"branchId": 120448,
"branchName": "TESTE TESTE1"
}
],
"application": [
{
"id": 50707344,
"score": 40.251965332031254,
"partnerName": "indeed",
"endedAt": null,
"createdAt": "2020-12-21T11:21:30.587Z",
"updatedAt": "2021-02-18T22:02:35.866Z",
"tags": {},
"candidate": {
"birthdate": "1986-04-04",
"id": 578615,
"name": "TESTE",
"lastName": "TESTE TESTE",
"email": "teste#teste.com.br",
"identificationDocument": "34356792807",
"countryOfOrigin": "BR",
"linkedinProfileUrl": "teste",
"gender": "female",
"mobileNumber": "+5511972319799",
"phoneNumber": "(11)2463-2039"
},
"job": {
"id": 619713,
"name": "XXXXde XXXX Pleno"
},
"manualCandidate": null,
"currentStep": {
"id": 3527370,
"name": "Cadastro",
"status": "done"
}
},
{
"id": 50707915,
"score": 3.75547943115234E+1,
"partnerName": "indeed",
"endedAt": null,
"createdAt": "2020-12-21T11:31:31.877Z",
"updatedAt": "2021-02-18T14:07:06.605Z",
"tags": {},
"candidate": {
"birthdate": "1971-10-02",
"id": 919358,
"name": "TESTE TESTE",
"lastName": "SILVA",
"email": "teste.teste#teste.com",
"identificationDocument": "3232323232",
"countryOfOrigin": "BR",
"linkedinProfileUrl": "teste/",
"gender": "female",
"mobileNumber": "11 94021- 5521",
"phoneNumber": "+5511995685247"
},
"job": {
"id": 619713,
"name": "Analista de XXXXX Pleno"
},
"manualCandidate": null,
"currentStep": {
"id": 3527370,
"name": "Cadastro",
"status": "done"
}
}
]
}
My question is: How can I extract only the array objects in jobs and application separately? Anyone knows the code in Mongodb for do this?
I need do this task for after I can insert the extract separated data in different collections.
Thanks a lot.
Unfortunately there is no real "good" way of doing this. Here is an example of how I would do it by using $facet and other operators to manipulate the structure
db.collection.aggregate([
{
$match: {
/** your query*/
}
},
{
$facet: {
jobs: [
{
$unwind: "$jobs"
},
{
$replaceRoot: {
newRoot: "$jobs"
}
}
],
applications: [
{
$unwind: "$application"
},
{
$replaceRoot: {
newRoot: "$application"
}
}
]
}
},
{
$addFields: {
"merged": {
"$concatArrays": [
"$jobs",
"$applications"
]
}
}
},
{
$unwind: "$merged"
},
{
"$replaceRoot": {
"newRoot": "$merged"
}
}
])
Mongo Playground
I would personally just do it in code after you fetched the document.
I want to get insights and breakdowns for all ad campaigns for an account. I am almost certain that I can not get publisher_platform from the breakdowns because we are using the campaigns Edge. Is there some other method of getting what network/publisher_platform a campaign is being run on?
Request
act_XXX/campaigns?fields=insights{impressions,account_id,account_currency,spend,cost_per_inline_link_click,actions,website_ctr},effective_status,start_time,stop_time&limit=1&breakdowns=publisher_platform&time_rage={"since":"2018-01-02","until":"2018-02-02"}
Response
"data": [
{
"insights": {
"data": [
{
"impressions": "90",
"account_id": "111111111111",
"account_currency": "USD",
"spend": "0.69",
"actions": [
{
"action_type": "comment",
"value": "2"
},
{
"action_type": "photo_view",
"value": "2"
},
{
"action_type": "post_reaction",
"value": "10"
},
{
"action_type": "page_engagement",
"value": "14"
},
{
"action_type": "post_engagement",
"value": "14"
}
],
"date_start": "2018-12-16",
"date_stop": "2019-01-14"
}
],
"paging": {
"cursors": {
"before": "MAZDZD",
"after": "MAZDZD"
}
}
},
"effective_status": "ACTIVE",
"start_time": "2019-01-14T12:52:16-0600",
"stop_time": "2019-01-21T12:52:13-0600",
"id": "23843254853610607"
}
],
"paging": {
"cursors": {
"before": "QVFIUkdVQ1p2ZATVNb01JUE55dU9VWWQ3MmxYTTNkSVRNQlI0alg4N2lzZA2FRZAGNDSzVvcDZAhTEF0RDJoZAWVHT09KTjVTeTBIMVpoQ0lmN3Q2djI3b2E2ek9n",
"after": "QVFIUkdVQ1p2ZATVNb01JUE55dU9VWWQ3MmxYTTNkSVRNQlI0alg4N2lzZA2FRZAGNDSzVvcDZAhTEF0RDJoZAWVHT09KTjVTeTBIMVpoQ0lmN3Q2djI3b2E2ek9n"
},
"next": "https://graph.facebook.com/v3.0/act_xxxxx/campaigns?access_token=xxxxxxxx"
}
}
I find it extremely frustrating that this request returns a response at all since it is not respecting the breakdown parameter.
This has been asked 8 months ago but answering for people who have the same question.
Use
act_XXX/campaigns?fields=insights.fields(<fields>).breakdowns(<breakdowns>)
So in your case, it's
act_XXX/campaigns?fields=insights.fields(impressions,account_id,account_currency,spend,cost_per_inline_link_click,actions,website_ctr).breakdowns(publisher_platform),effective_status,start_time,stop_time&limit=1&time_rage={"since":"2018-01-02","until":"2018-02-02"}