Hi guys, my first post here. I’m really enjoying using N8N and at the moment I have a challenge.
I need to break a string value into 5 different fields.
the value is
source=FacebookAds_medium=001 - [3P] - All Visitors - 180D [IG] Laschuk - 30D_campaign=[L03] [VIP] [LEAD] - Posts Aulas_term=_content=Ad3 - Carousel Card VIP List L03
I need to convert to:
- utm_source = FacebookAds
- utm_medium = 001 - [3P] - All Visitors - 180D [IG] Laschuk - 30D
- utm_campaign = [L03] [VIP] [LEAD] - Posts Classes
- utm_term = Instagram_Feed
- utm_content = Ad3 - Carousel Card VIP List L03
How can I do this using just expression or javascript?
Thx!
You can use some javascript in a Code node, like this:
2 Likes
wooow! works perfect. thanx sooo much!
and now, how can I take the source value?
[
{
"page_info":
{
"results_per_page":
1,
"total_results":
1
},
"items":
[
{
"product":
{
"id":
1367093,
"name":
"TESLABOT"
},
"purchase":
{
"commission_as":
"PRODUCER",
"payment":
{
"method":
"HOTMART",
"type":
"WALLET",
"installments_number":
1
},
"tracking":
{
"source":
"source=FacebookAds_medium=001 - [3P] - All Visitors - 180D [IG] Laschuk - 30D_campaign=[L03] [VIP] [LEAD] - Posts Aulas_term=Instagram_Feed_content=Ad3 - Carrossel Card Lista VIP L03"
},
"warranty_expire_date":
1667692800000,
"offer":
{
"code":
"6r44sesq",
"payment_mode":
"UNIQUE_PAYMENT"
},
"approved_date":
1667182038000,
"hotmart_fee":
{
"fixed":
0,
"total":
20,
"base":
0.78,
"currency_code":
"BRL"
},
"order_date":
1667182038000,
"price":
{
"value":
3.9,
"currency_code":
"BRL"
},
"status":
"APPROVED",
"is_subscription":
false,
"transaction":
"HP101116671820384"
},
"producer":
{
"ucode":
"f53d61cd-77a6-4425-814b-fd2246070271",
"name":
"hug.business"
},
"buyer":
{
"ucode":
"5ef8f680-d6f0-4da9-b8e6-f022778a7cdb",
"name":
"andrea aaaa",
"email":
"[email protected]"
}
}
]
}
]
im trying to use this code, but no success:
return $("Consulta").item.json['source'];
the error:
ERROR: Code doesn’t return an object [item 0] Please return an object representing the output item. (‘undefined’ was returned instead.)