What if you tracked the event's parents, e.g. button <- div <- .sidebar <- body, etc.? When presenting the events to the user, you could hide generic parents like 'div' and only show interesting parents with ids or classes. To search through events, perhaps the user could use css selector syntax in addition to the current UI you have.