Convert Collection of Values

I am using an HTTPS request to retrieve data from Facebook Insights. I receive the data as shown in the screenshot. Is it possible to modify the data to achieve the following structure:

Campaign Name: Sales
Spend: 2671.78
Reach: 68748
Impressions: 304904
Clicks: 2468
Likes: 4
Link Clicks: 1572
Comments: 3
Post Reactions: 51

I would like to do this to be able to place it in 1 row in Google Sheets.

Can you please send an output of the module. This allows us to help easier

[
{
“statusCode”: 200,
“headers”: [
{
“name”: “content-encoding”,
“value”: “br”
},
{
“name”: “etag”,
“value”: “"a8df70cfd856a4d676340c6b7628348499cc4ae1"”
},
{
“name”: “content-type”,
“value”: “application/json”
},
{
“name”: “vary”,
“value”: “Origin, Accept-Encoding”
},
{
“name”: “x-business-use-case-usage”,
“value”: “{"3028312990794511":[{"type":"ads_insights","call_count":1,"total_cputime":1,"total_time":1,"estimated_time_to_regain_access":0,"ads_api_access_tier":"development_access"}]}”
},
{
“name”: “x-fb-ads-insights-throttle”,
“value”: “{"app_id_util_pct":0.01,"acc_id_util_pct":0,"ads_api_access_tier":"development_access"}”
},
{
“name”: “access-control-allow-origin”,
“value”: “*”
},
{
“name”: “facebook-api-version”,
“value”: “v20.0”
},
{
“name”: “strict-transport-security”,
“value”: “max-age=15552000; preload”
},
{
“name”: “pragma”,
“value”: “no-cache”
},
{
“name”: “cache-control”,
“value”: “private, no-cache, no-store, must-revalidate”
},
{
“name”: “expires”,
“value”: “Sat, 01 Jan 2000 00:00:00 GMT”
},
{
“name”: “x-fb-request-id”,
“value”: “AsfAJTdZyLh7IUqh-ylUtl9”
},
{
“name”: “x-fb-trace-id”,
“value”: “F6X2W6nn8rl”
},
{
“name”: “x-fb-rev”,
“value”: “1014843003”
},
{
“name”: “x-fb-debug”,
“value”: “1WIZqzzPURE20wHn/PFr3dWpDl7xD8qvWY0cMfkZWmac7JNCEfECJ3jCZHIFOas4cI71ryPX7YL2psXbBOqSHg==”
},
{
“name”: “date”,
“value”: “Fri, 12 Jul 2024 16:56:48 GMT”
},
{
“name”: “x-fb-connection-quality”,
“value”: “EXCELLENT; q=0.9, rtt=16, rtx=0, c=10, mss=1380, tbw=3404, tp=-1, tpl=-1, uplat=541, ullat=0”
},
{
“name”: “alt-svc”,
“value”: “h3=":443"; ma=86400”
},
{
“name”: “connection”,
“value”: “keep-alive”
},
{
“name”: “content-length”,
“value”: “419”
}
],
“cookieHeaders”: ,
“data”: {
“data”: [
{
“campaign_name”: “camp1”,
“spend”: “2671.78”,
“reach”: “68748”,
“impressions”: “304904”,
“clicks”: “2468”,
“actions”: [
{
“action_type”: “like”,
“value”: “4”
},
{
“action_type”: “link_click”,
“value”: “1572”
},
{
“action_type”: “comment”,
“value”: “3”
},
{
“action_type”: “post_reaction”,
“value”: “51”
}
],
“date_start”: “2024-04-13”,
“date_stop”: “2024-07-11”
},
{
“campaign_name”: “camp2”,
“spend”: “50”,
“reach”: “7846”,
“impressions”: “12157”,
“clicks”: “1108”,
“actions”: [
{
“action_type”: “link_click”,
“value”: “510”
},
{
“action_type”: “post_reaction”,
“value”: “1”
}
],
“date_start”: “2024-04-13”,
“date_stop”: “2024-07-11”
},
{
“campaign_name”: “camp3”,
“spend”: “20.52”,
“reach”: “1041”,
“impressions”: “1370”,
“clicks”: “64”,
“actions”: [
{
“action_type”: “link_click”,
“value”: “28”
}
],
“date_start”: “2024-04-13”,
“date_stop”: “2024-07-11”
},
{
“campaign_name”: “camp4””,
“spend”: “200”,
“reach”: “11173”,
“impressions”: “16438”,
“clicks”: “1258”,
“actions”: [
{
“action_type”: “link_click”,
“value”: “569”
},
{
“action_type”: “post_reaction”,
“value”: “5”
}
],
“date_start”: “2024-04-13”,
“date_stop”: “2024-07-11”
}
],
“paging”: {
“cursors”: {
“before”: “MAZDZD”,
“after”: “MwZDZD”
}
}
},
“fileSize”: 1289
}
]

Hi @Pawel_Piekarski thank you for this it helped me solve it for you. You can use the blue print also.
blueprint (21).json (11.4 KB)

But, I used an iterator after the data to to get all of the data into separate bundles. Then I used toCollection which makes a collection of key value pairs that we defined this was the step that you were missing. Then you are able to get the data you need to add the row into google sheets.


3 Likes

It works! Thank you! :wink:

3 Likes