One of the tricks to get around this limitation if you don’t have an ID is to earlier (e.g. on DOM ready event) run a separate tag to add ID to element that doesn’t have it. For example:
Can this somehow be done solely in Piwik (Tag Manager?) or does it have to be added to application code?
Also, any plans to support the type of selectors we see elsewhere in Tag Manager? Creating custom events, for example, can be done without requiring ID’s on elements.
Hang on @Michael don’t take the time yet, I re-read your message and seems like you are saying that there is a way to do this with a tag. I will try and either succeed or fail and let u know!
Hey @michaelf, thanks for the feedback!
I see that you have “Fire tag once per session” selected in the trigger. I think this is why it might not run for you when you’re testing - it did once, and then it won’t for the time of the session. Make sure to allow “Fire tag multiple times” and check then - it should work. If not - please post a link to the page you’re testing on.
Yes, that would be just the reason. Element that you want to add the ID to, is not available at the time of running the tag.
There are multiple ways to go about this:
easy way - delay running the tags to Page Load state, but that can cause undesired flickering of the personalised element
less-easy way - send a dataLayer event from your website when the element is rendered, and base your trigger on that dataLayer event
hard way - employ mutationObserver to observe your site as it loads to find that given element has been already loaded, and then execute tag for adding the ID
I hope those suggestions will be useful for you. Don’t hesitate to ask further if you have any questions!