title: How to grab a hidden input's attributes using Google Tag Manager Click Event
body: <p>I have hidden inputs being created dynamically and populated using angularjs like so:</p>
  
  <pre><code>&lt;input type="hidden" id="input-{{counter_here}}" name="{{dynamic_name_here}}"
      value="dynamic_value_here" /&gt;
  </code></pre>
  
  <p>I want to use Google Tag Manager (GTM) to track some data based on the <code>input</code>s' attriibutes.</p>
  
  <p>I'm using javascript like so</p>
  
  <pre><code>for(var i = 0; i &lt; my_array.length; i++){
      $('#input-' + i).click();
  }
  </code></pre>
  
  <p>... so that I can fire a click event on each of these <code>input</code>s (as there could be multiple instances of these <code>input</code>s), thereby triggering a tag in GTM.</p>
  
  <p>I know that in GTM I can use the built in variable "Click ID" to get the <code>id</code> attribute of the input when clicked. But what I need is the <code>name</code> and <code>value</code> attributes to be recorded; the <code>name</code> in GTM's 'action' and the <code>value</code> in GTM's 'label'. GTM's 'value' can be left as default.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've tried using</p>
  
  <pre><code>{{Click Element}}.getAttribute('name') // and
  {{Click Element}}.getAttribute('value')
  </code></pre>
  
  <p>... like so:</p>
  
  <p><a href="https://i.stack.imgur.com/DA8nZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DA8nZ.png" alt="enter image description here"></a></p>
  
  <p>But when I preview I just get a string returned instead of the values:</p>
  
  <p><a href="https://i.stack.imgur.com/NJVD4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NJVD4.png" alt="enter image description here"></a></p>