I would like to know pros and cons of nested and flat data layer to implement on a web property? Also, would like to understand if there any concerns related with implementing anyone of the data layer method with respect to Adobe Launch (TMS)?
We at Search Discovery have put a ton of thought into this topic - so much, in fact, that we've created an extension for Launch called the "Data Layer Manager". I'll get to that later, but for now, let's talk flat versus hierarchical...
I am not a fan of flattened data layers an I'll show you why.
Consider this hierarchical JSON object representing an Order Placed event on an e-commerce website :
Now, let's flatten it.
Although the flattened version might seem more easily created and understood than the hierarchical one there is a big problem.
When we try to represent Arrays of Objects in a flattened manner, we become reliant on the perfect alignment of multiple Arrays.
Consider the scenario where something breaks in the generation of these arrays (and yes, things WILL break. they always do. and they break in strange ways). Below is one scenario where we ended up with 3 items in all arrays except the sku array which only has two.
The question here is, "How should you align the sku array with the others?" The answer is, "You can't".
In practice, you would probably get the 2nd sku aligned with the 2nd productID, sellingPrice, and quantity which would lead to strange reports that leave analysts scratching their heads. The 3rd productID would go without a sku which again, would lead to compromised reporting. Now consider large orders and the possibilities for misalignment there...
Here's one more example to make my case against flat data layers.
Consider this scenario where we want to represent the contents of a product bundle along with the inventory status of the various skus for each product in the bundle. The hierarchical approach can easily handle this with arrays of objects within arrays of objects.
Let's put that object through Tealium's flattener...
We end up with two productIDs, five skus, and five inventory states. We cannot realign these arrays in any meaningful way.
Now a bit about the Data Layer Manager extension.
What value do you get from using it?
Below is a diagram showing the interaction between the Application (your website), the data layer (labeled window.AppEventData), the Data Layer Manager extension and Launch in time sequence from top to bottom. (Click the image for an expanded view).