Last active
June 28, 2017 16:45
-
-
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]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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