Moin!
Warum nicht einfach:
<?php
$items['transactionId'] = "12345";
$items['transctionTotal'] = "46,30 Euro";
$items[0][product_ean] = "1";
$items[0][product_name] = "Produkt 1";
$items[0][category] = "Kategorie 1";
$items[0][product_item_price] = "10,00 Euro";
$items[0][product_quantity] = "1";
?>
<script>
dataLayer = [<?php echo json_encode($items); ?>]
</script>
???
Bei mir kommt da
<script>
dataLayer = [{"transactionId":"12345","$transctionTotal":"46,30 Euro","0":{"product_ean":"1","product_name":"Produkt 1","category":"Kategorie 1","product_item_price":"10,00 Euro","product_quantity":"1"},"1":{"product_ean":"2","product_name":"Produkt 2","category":"Kategorie 2","product_item_price":"20,00 Euro","product_quantity":"2"},"2":{"product_ean":"3","product_name":"Produkt 3","category":"Kategorie 3","product_item_price":"30,00 Euro","product_quantity":"3"}}]
</script>
(als Einzeiler) raus.
Jörg Reinholz