Post by xoomit » Fri Dec 11, 2015 11:30 pm

Hi OC-community,

I want to add a data Layer to the confirmation.tpl so that I could fire the GA e-commerce tag via the Tag Manager once the customer clicks on "Confirm".

I tried using this code:

Code: Select all

<script>
  dataLayer = [{
      'transactionId': '<?php echo $order_id ?>',
      'transactionTotal': <?php echo $total ?>,
      'transactionTax': <?php echo $tax ?>,
      'transactionShipping': <?php echo $shipping ?>,
    <?php
      $n=sizeof($order_data['products']);
      for ($i=0; $i < $n; $i++) {
    ?>  
      'transactionProducts': [{
          'sku': '<?php echo $product['product_id'] ?>',
          'name': '<?php echo $product['name'] ?>',
          'price': <?php echo $product['price'] ?>,
          'quantity': <?php echo $product['quantity'] ?>
       }]
    <?php } ?>
  }];
</script>
Unfortunately, this crashes the checkout. Does anyone see what the problem is?

Thanks & best,
Torge

New member

Posts

Joined
Tue Jun 19, 2012 6:09 am
Who is online

Users browsing this forum: No registered users and 45 guests