• Resolved alezucchi

    (@alezucchi)


    Hello, can you tell me the php variable to push the brand into data layer?

    I tried something like

    <script>
    	window.dataLayer = window.dataLayer || [];
          dataLayer.push({
              'event' : 'acquisto',
    		  'ecommerce': {
                'currencyCode': '<?php echo $order->get_order_currency(); ?>',
                'purchase': {
                  'actionField':{
                    'id': '<?php echo $order->get_order_number(); ?>',
                    'affiliation': 'WooCommerce',
                    'revenue': <?php echo number_format($order->get_subtotal(), 2, ".", ""); ?>,
                    'tax': <?php echo number_format($order->get_total_tax(), 2, ".", ""); ?>,
                    'shipping': <?php echo number_format($order->calculate_shipping(), 2, ".", ""); ?>,
                    <?php if($order->get_used_coupons()): ?>
                        'coupon': '<?php echo implode("-", $order->get_used_coupons()); ?>'
                    <?php endif; ?>
                  },
                  'products': [
                      <?php
                        foreach($order->get_items() as $key => $item):
                          $product = $order->get_product_from_item( $item );
                          $variant_name = ($item['variation_id']) ? wc_get_product($item['variation_id']) : '';
                      ?>
                          {
                            'name': '<?php echo $item['name']; ?>',
                            'id': '<?php echo $item['product_id']; ?>',
                             'price': '<?php echo number_format ($product->get_sale_price(), 2, ".", ""); ?>',
                            'variant': '<?php echo ($variant_name) ? implode("-", $variant_name->get_variation_attributes()) : ''; ?>',
    						   'brand': '<?php echo $brands['name']; ?>',
                            'quantity': <?php echo $item['qty']; ?>
                          },
                      <?php endforeach; ?>
                    ]
                }
              }
          });
        </script>

    but i gut empty field in data layer.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter alezucchi

    (@alezucchi)

    hello, can you help me?

    more specifically i’m trying to insert tis line to get brand in data layer

    ‘brand’: ‘<?php echo $brands[‘name’]; ?>’,

    thank you

    AZ

    Thread Starter alezucchi

    (@alezucchi)

    Hello
    please, help me grabbing the brand value and send it to data layer..

    Thread Starter alezucchi

    (@alezucchi)

    HELLO, AGAIN, PLEASE HELP

    I need to find with metakey is applied to a product when a brand is applied.

    I need to get the brand value to read it and send it to Google Analytics.

    Thank’s

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Data layer variable’ is closed to new replies.