Quick Tip #1: Copy Object – Google Chrome
Use Chrome DevTools' Copy object context menu to grab a clean, well-formatted copy of an object from the dataLayer.
This tip is about Google Chrome and copying objects from the Developer Tools.
When you query the dataLayer from the console, you get back an array of objects representing the different events.
dataLayer — Google Chrome console
If you want to copy one of these objects to the clipboard, there’s a small trick.
Up until now you might have used the mouse to highlight the object’s contents and copy them. The result, sadly, was a poorly formatted version of the object.
Another option was copy(). There you’d have to find the object’s index first, but at least the format was correct.
copy(dataLayer[0]);
Instead of going through the slightly more cumbersome copy(dataLayer[XY]) route, you can now also use the “Copy object” feature.
Copy object — Google Chrome
Just right-click the line of the object and you’ll get the context menu shown above.
I don’t think there’s a faster way to grab individual objects out of the dataLayer or other structures.