title: Track ALL clicked elements using JavaScript
body: <p>I want to track ALL elements that are clicked on a HTML-page. I need a good way to reference exactly which element was clicked (so I will be able to replay the clicks on a identical separate HTML-page later on).</p>
  <p><strong>Is there a good way to reference which element that was clicked?</strong></p>
  <p>I could add unique id's and classnames to every single element on the page. But I figure there must be another way?</p>
  <p>The HTML-page which I will be replaying the clicks on will be identical.</p>
  <p>Something like this (but more exact information which element it was, maybe that's possible to collect)...</p>
  <p><strong>Code to track which element was clicked</strong></p>
  <pre><code>var arrayWithElements = new Array();
  
  document.onclick = clickListener;
  
  function clickListener(e) {
      var clickedElement;
      if(e == null) {
          clickedElement = event.srcElement;
      } else {
          clickedElement = e.target;
      }
      arrayWithElements.push(clickedElement)
      alert(arrayWithElements);
  }
  </code></pre>
  <p><strong>Code that will be used on a identical HTML-page</strong></p>
  <pre><code>document.someHowGetTheElement().onclick();
  </code></pre>