I'm trying to figure out if there is a way to detect multiple custom HTML-5 attributes (i.e. "data-analytics-exp-name") and aggregate their values (with a delimiter) into a cookie using Adobe DTM without the user being involved (attributes only need to exist on the page and not be clicked on etc.).
I currently have a rule that reads a single custom HTML-5 attribute and performs what I want using an event type of "element exists" and using:
var currExpName = this.getAttribute('data-analytics-exp-name');
but not sure how to approach for multiples at once?
If you're looking to get all attributes on the page, you will want to use something that can access the whole page. Try the following code:
`document.querySelectorAll("[data-analytics-exp-name]");
This should return all DOM elements containing the attribute data-analytics-exp-name
. From there you can parse the array however you'd like to get the concatenated string you're looking for.