title: How to properly use dataLayer.push(), to update values, of nested objects, in an array?
body: <p>Here is my dataLayer array:</p>
  
  <pre><code>dataLayer = [{
    'giftBatch' : {
      'giftID': '',
      'giftAmount': 0,
      'giftCount': 0,
      'giftUpdate': {
        'giftPhase': 'Gift Empty'
      }
    },
    'txBatch': {
      'txID': '',
      'txTotal': 0,
      'txURL': window.location.href,
      'txUpdate': {
        'txPhase': 'Transaction Opened',
        'txT0': new Date(),
        'txT1': ''
        'txT2': ''
      }
    }
  }];
  </code></pre>
  
  <p>The console results are: Array [Object1]</p>
  
  <p>Object1 contains the 'giftBatch' and 'txBatch' Objects, as desired.</p>
  
  <p>I have a trigger that fires later to update the object in the dataLayer.</p>
  
  <p>For example, update the 'giftAmount' to 50 and 'giftCount' to 1.</p>
  
  <p>I have tried the following (I am only showing my unsuccessful attempts at modifying 'one object at a time'),</p>
  
  <p><strong>Attempt 1:</strong></p>
  
  <pre><code>dataLayer.push({giftAmount : 50});
  </code></pre>
  
  <p><strong><em>Result:</em></strong></p>
  
  <p>Array [object1, object2]</p>
  
  <p>Object1 is the same as above,</p>
  
  <p>Object2 is a new object with the property of <em>'Gift Amount' : 50</em>,</p>
  
  <p><strong>Attempt 2:</strong></p>
  
  <pre><code>dataLayer.push({giftBatch.giftAmount: 222});
  </code></pre>
  
  <p><strong><em>Result:</em></strong> SyntaxError: missing : after property id</p>
  
  <p><strong>Attempt 3:</strong></p>
  
  <pre><code>dataLayer.push({'giftBatch.giftAmount' : 50});
  </code></pre>
  
  <p><strong><em>Result:</em></strong></p>
  
  <p>Array [object1, object2]</p>
  
  <p>Object1 is the same as above,</p>
  
  <p>Object2 is a new object with the property <em>'giftBatch.giftAmount': 50</em></p>
  
  <p>What am I doing wrong here?</p>
  
  <p>According to the dataLayer section here: <a href="https://support.google.com/tagmanager/answer/6106899?hl=en" rel="noreferrer">https://support.google.com/tagmanager/answer/6106899?hl=en</a></p>
  
  <p>I should be able to edit nested objects values.</p>
  
  <p>PS. This is what I'm using now, and it does work. But, why doesn't push work? </p>
  
  <pre><code>dataLayer[index].giftBatch.giftAmount = 50;
  </code></pre>
  
  <p><em>Where index is the index of Object2.</em></p>
  
  <p>Any help would be great.</p>
  
  <p>Thank you.</p>