JoinBy (deprecated)
Joins two lists by keys and returns selected values.
The JoinBy node helps you to join two lists based on a set of conditions, e.g. to join
- Facebook Insights and Ads based on the ad id
- Facebook Adsets and Campaigns based on the campaign id
- two Facebook Insights for different timeframes based on the ad object id
- or whatever else you wish ✨
How to use the JoinBy node
Connect your main list to socket a
and your second list to socket b
. The config
socket contains three parts:
- conditions
- list_alias
- selections
{
"conditions": [],
"list_alias": {},
"selections": {}
}
The JoinBy node works similar to how the “LEFT JOIN” statement in SQL works.
Conditions
The most important to determine how the two lists should be joined is the conditions part. For example if you want to join data at the ad level, you may choose the ad id as the only condition. E.g. if you want to join Facebook Insights data on ad level and Facebook ads, the ad id shows up as ad_id
in the insights data and as id
in the ads:
[
{
"a": "ad_id",
"b": "id"
}
]
When joining the ads to your insights, you may not want to add all fields or have them show up with a particular name.
List Aliases
Use the list_alias
field to identify each list in the newly created list. The alias will be prepended to each field. You can simply leave both empty, i.e. as empty strings, too.
{
"a": "",
"b": ""
}
Selections
If you don’t want to add all data, you can use the selections
field. To choose all fields from a list simply use "*"
. If you only want to add individual fields you can do so specifying and an optional alias.
{
"a": "*",
"b": [
{
"key": "effective_status",
"alias": "ad_status"
}
]
}
Putting it together
Let’s complete the example assuming we have Facebook insights data and Facebook ads in sockets a and b, respectively.
[
{
"spend": 25.23,
"ad_id": "123456789"
}
]
[
{
"name": "Ad Name 123",
"effective_status": "ACTIVE",
"id": "123456789"
}
]
Using the entire config
field we can now join the data:
{
"conditions": [
{
"a": "ad_id",
"b": "id"
}
],
"list_alias": {
"a": "",
"b": ""
},
"selections": {
"a": "*",
"b": [
{
"key": "effective_status",
"alias": "ad_status"
}
]
}
}
Result:
[
{
"spend": 25.23,
"ad_id": "123456789",
"ad_status": "ACTIVE"
}
]
Last updated on January 31, 2023