Joining Array Variables for Adobe Analytics classification

Gold Contributor
Gold Contributor
Hi all, We are looking to join three variables together into a single eVar. These are all in our data layer as arrays. Ideally this would work best as: Quantities:Sizes:Upload_Status What would be the proper way to join these together to achieve the desired output of _Quantities 0 125:M:No_Upload 1 275:L:LowRes 2 100:S:HiRes etc Thank you!
6 REPLIES 6

Joining Array Variables for Adobe Analytics classification

Tealium Employee
Hello Kevin, Try this in google chrome console: var a = ["a1","a2","a3"]; var b = ["b1","b2","b3"]; var c = ["c1","c2","c3"]; var d = []; for (var i = 0; i < a.length; i++) { d[i] = ([a[i], b[i], c[i]]).join(":"); } var e = d.join("|");

Joining Array Variables for Adobe Analytics classification

Gold Contributor
Gold Contributor
The output from that is "a3:b3:c3" in console for me. The main reason I am posting in here looking for help is that I've had difficulty working with joining variables to be used in the product string in Adobe Analytics (and I'm a bit new to working with arrays).

Joining Array Variables for Adobe Analytics classification

Tealium Employee
if you look at variable e, it contains everything concatenated in one string, separated by colon matching the array index and pipes. This code here is obviously just an example. What UDO variable array names do you have these values in?

Joining Array Variables for Adobe Analytics classification

Gold Contributor
Gold Contributor
The variables above are the actual working vars, in this case.

Joining Array Variables for Adobe Analytics classification

Tealium Employee
Hi Kevin, Try this. In a JavaScript extension, you need to refer to "b" to get access to the consolidated data layer. Remember you will also need to map the data source "data_sources_joined" to the final evar destination in the tag's mapping table. /** * join 3 arrays with data into 1 data source example */ if (b.Quantities && b.Quantities.length) { for (var i = 0; i < b.Quantities.length; i++) { var joined = []; joined.push(b.Quantities[i]); // if Sizes at array index i exist if (b.Sizes && b.Sizes[i]) { joined.push(b.Sizes[i]); } // if Upload_Status at array index i exist if (b.Upload_Status && b.Upload_Status[i]) { joined.push(b.Upload_Status[i]); } // join the data at array index i with a colon separator b.data_sources_joined[i] = joined.join(":"); } // finalize the data with pipe separator b.data_sources_joined = data_sources_joined.join("|"); }

Joining Array Variables for Adobe Analytics classification

Gold Contributor
Gold Contributor
Hi Kevin, I've given this a shot, and I'm not seeing this new variable in in the data layer. I'm using DataSlayer to debug.
Public