title: Can I watch for changes to datalayer variables in Google Tag Manager?
body: <p>I am writing a Javascript function that will be a tag in Google Tag Manager.</p>
  
  <p>It is loaded on a SPA which I have minimal control over.</p>
  
  <p>Whenever a user clicks, I use the GTM functionality to push some data to the datalayer, e.g.:</p>
  
  <pre><code>var someEventIsTriggered = function(e) {
          var target = $('input#watched');
  
          // Trigger a generic "gtm.click" event on every click
          dataLayer.push({
              "event": "gtm.customEvent",
              "gtm.customWatchedVariable": target.val()
          });
  };
  </code></pre>
  
  <p>Every time this is triggered, it will push a new event to the datalayer, and updated the value of gtm.customWatchedVariable. What I now want to check is if the current <code>gtm.customWatchedVariable</code> is different from the last <code>gtm.customWatchedVariable</code>, and then fire a Trigger in GTM when it changes.</p>
  
  <p>How can I do this?</p>