Skip to content

Instantly share code, notes, and snippets.

@moakdesigns
Last active June 28, 2017 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moakdesigns/458872ee8accc5ec8129caa9e6ee7c07 to your computer and use it in GitHub Desktop.
Save moakdesigns/458872ee8accc5ec8129caa9e6ee7c07 to your computer and use it in GitHub Desktop.
Chrome DevTools Console Hack to list all Data Attributes in table view. Credits to: https://www.thyngster.com/tip-quickly-debugqa-data-attributes/ For GTM I assume. [updated June 28, 2017]
(function() {
var elements = [].slice.call(document.querySelectorAll('*')).filter(function(el) {
if (typeof (el.dataset) != "undefined")
return Object.keys(el.dataset).length != 0;
});
var data = [];
var i = elements.length;
while (i--) {
var el = JSON.parse(JSON.stringify(elements[i].dataset));
data.push(el);
el["_element_type"] = elements[i].nodeName;
}
console.table(data);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment