title: JS add array in tracking code push method
body: <p>I've been trying since yesterday to pass an array in a push method.</p>
  
  <p>There is a tracking code called Criteo and they required to fill the following to make it work. Everything's fine except the viewBasket.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    window.criteo_q = window.criteo_q || [];
    window.criteo_q.push(
    { event: "setAccount", account: 11111 },
    { event: "setEmail", email: "username@domain.com" },
    { event: "setSiteType", type: "d" },
    { event: "viewBasket", item: [
      { id: "product_id_1", price: price_1, quantity: quantity_1 },
      { id: "product_id_2", price: price_2, quantity: quantity_2 }
      /* add a line for each item in the user's basket */
    ]}
  );
  &lt;/script&gt;
  </code></pre>
  
  <p>So I created an array and populated it with the data Criteo requires (which is the product id, the price and the quantity). Although in the console I could see the correct structure, when I pass it in the code it does not work.</p>
  
  <p>In the console I can see this (first part is the two lines I pushed into array, and second one is the whole array):</p>
  
  <pre><code>{ id:"20020-278", price: 119, quantity: 1},
  { id:"20009-129", price: 927, quantity: 3},
  
  Array[2]
  0: "{ id:"20020-278", price: 119, quantity: 1},"
  1: "{ id:"20009-129", price: 927, quantity: 3},"
  length: 2__proto__: Array[0]
  </code></pre>
  
  <p>Exactly as I want it but for some reason it does not work. I tried to convert it to JSON array or just pass a normal line with no variables and I still have this problem. I also escaped that symbol <strong>{</strong> ..</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      ...
      ...
      var full_line = "\{ id:\""+pid+"\", price: "+price+", quantity: "+quantity+"\},";
      //var full_line = "\{ id:20020-278, price:119, quantity:1\},";
      //var full_lineJson = JSON.stringify(full_line);
  
      console.log(full_line);
      allitems.push(full_line);
  &lt;/script&gt;
  </code></pre>
  
  <p>I pass the 'allitems' array in Criteo code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    window.criteo_q = window.criteo_q || [];
    window.criteo_q.push(
    { event: "setAccount", account: 11111 },
    { event: "setEmail", email: "username@domain.com" },
    { event: "setSiteType", type: "d" },
    { event: "viewBasket", item: [
           allitems
    ]}
  );
  &lt;/script&gt;
  </code></pre>
  
  <p>On Criteo debug page is displayed like this:</p>
  
  <p><a href="https://i.stack.imgur.com/jgToO.png" rel="nofollow"><img src="https://i.stack.imgur.com/jgToO.png" alt="enter image description here"></a></p>
  
  <p>The result should be:</p>
  
  <pre><code>Product ID   Price   Quantity
  20010-278      69       1
  </code></pre>
  
  <p>But as you can see the structure is broken somehow. I tried so many different ways and still didn't manage to fix this. There is something wrong with the structure in array but I am not sure what else I can do. Any suggestions please? </p>
  
  <p><strong>EDIT: If I pass an object</strong></p>
  
  <pre><code>Object {product_id: "20020-278", price: "119", quantity: "1"}
  Object {product_id: "20009-129", price: "927", quantity: "3"}
  
  Array[2]
  0: Object
  price: "119"
  product_id: "20020-278"
  quantity: "1"
  
  __proto__: Object
  
  1: Object
  price: "927"
  product_id: "20009-129"
  quantity: "3"
  
  __proto__: Object
  
  length: 2__proto__: Array[0]
  </code></pre>
  
  <p>Criteo site displays this error when I use objects:
  Product ID info missing: "item" property is missing</p>
  
  <p>Code I used for objects:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      ...
      var full_line = {};
          full_line.product_id = product_id;
          full_line.price = price;
          full_line.quantity = quantity;
      allitems.push(full_line);
      ...
  &lt;/script&gt;
  </code></pre>
  
  <p>Then I just used the allitems inside the Criteo "viewBasket", item property.</p>