- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
09-29-2014 06:55 AM - last edited on 12-15-2015 10:57 AM by kathleen_jo
I have a UDO variable populated as a list ("item1, item2, item3") and a Criteo tag needs to receive an array.
How can I convert this variable into array just for this tag?
Thanks!
Best regards,
Solved! Go to Solution.
09-29-2014 07:06 AM - last edited on 12-15-2015 10:56 AM by kathleen_jo
Hi Lluis,
You can used a scoped Set Data values extension. This means that any data transformation you perform in that extension will only exist within the scope of the selected tag.
Using the JS code input you can then do something like:
b['products'].split(',')
The b object is the current working object that contains all of the UDO. The split function will then create an array using the character defined as the separator.
12-15-2015 11:07 AM
12-15-2015 11:13 AM
Is it possible to do the opposite (IE, convert an array to a string)? We have our product_sku variable as an array site-wide even when there's only one product and one vendor is taking issue with this and what's us to pass it as a string.
12-15-2015 11:13 AM
Hi Jeremy,
The javascript for this is would be:
b['product_skus'].join('|')
The character being what you want to use to separate the entires (normally provided in the tags documentation). You would then scope this extension to just that tag so this modification would only take place in the scope of this tag and therefore would not affect your other tags.
12-15-2015 11:14 AM
Hi,
That didn't work. I've also tried the below variations of this code and they had the following results.
b.'product_skus'.join('|') = broke the container
b.product_skus.join('|') = still an array
12-15-2015 11:14 AM
Hi Jeremy,
if you contact support we will be able to more efficiently help you with your request.
But I believe you issue was you missed the brackets off the first try but also I typed product_skus as an example and you mentioned product_sku in your message. So you would need to adjust for that.
Copyright All Rights Reserved © 2008-2023