Google Tag Manager - Data Layer Variable undefined
<p>I want to use product IDs as Label in an Google Tag Manager Trigger.
I have a populated Data Layer.
When in Chrome Console I use </p>

<pre><code>dataLayer[1].ecommerce.detail.products[0].id
</code></pre>

<p>I get as output a valid product ID.</p>

<p>When in Google Tag Manager I create a custom javascript variable and try:</p>

<pre><code>function(){
    var art_nr =  dataLayer[1].ecommerce.detail.products[0].id;
    return art_nr;
}
</code></pre>

<p>This variable later in the debuger just contains 'undefined'.</p>

<p>I did research for a few hours now, but I cant find a simple explanation on how to do this.</p>