Hello I am looking for help with woocommerce to add a code to the order confirmation thank you page. I need the get the following order variables inside [ ] and insert the woocommerce code to get the actual woocommerce values.
<script data-cfasync="false">
window.juapp=window.juapp||function(){(window.juapp.q=window.juapp.q||[]).push(arguments)}
/*
Replace the [order ...] portions below with the actual order information.
You can omit any of the attributes that you don't have values for other then the order id and order total.
*/
juapp(
  'order',
  '[order id]',
  {total:[order total],subtotal:[order subtotal],tax:[order tax],shipping:[order shipping],currency:'USD'}
);
/*
You will need to repeat this line of code for each item in the order.
Replace the [item ...] portions below with the actual item information in order.
You can omit any of the attributes that you don't have values for other then the item id and quantity.
*/
juapp(
  'orderItem',
  '[item id]',
  {name:'[item name]',quantity:[item quantity],price:[item price],color:'[item color]',size:'[item size]'}
);
/* end of repeat section */
</script>
I have looked over this page but need help with the code. https://docs.woocommerce.com/document/custom-tracking-code-for-the-thanks-page/
Also you can see more about the conversion code here https://support.justuno.com/general-conversion-code-installation
Let me know if any questions			
Alex Miller answers:
								Below is a function you can copy and paste into a theme, child theme, or build as a separate plugin. The easiest solution is to mix Javascript and PHP to add in the order properties to the tracking script. If you have any questions let me know!
/**
 * Add tracking code to WooCommerce Thank You page
 * 
 * @param Integer $order_id
 * 
 * @return void
 */
function jwt_woocommerce_thankyou_juapp_tracking( $order_id ) {
	
	// Lets grab the order
	$order = wc_get_order( $order_id );
	
	// Let's grab the order items
	$line_items = $order->get_items();
	
	?>
	
		<script data-cfasync="false">
			window.juapp=window.juapp||function(){(window.juapp.q=window.juapp.q||[]).push(arguments)}
			
			juapp(
				'order',
				'<?php echo $order->get_ID(); ?>',
				<?php
					printf( '{total:\'%1$s\',subtotal:\'%2$s\',tax:\'%3$s\',shipping:\'%4$s\',currency:\'USD\'}',
						$order->get_total(),
						$order->get_subtotal(),
						$order->get_cart_tax(),
						$order->get_shipping_total()
					);
				?>
			);
			
			<?php foreach( $line_items as $item )  :
					$product = $item->get_product();
					$attributes = $item->get_formatted_meta_data( '_', true );
					$script_atts = array(
						'color' => '',
						'size'  => '',
					);
					
					if( $product->is_type( 'variation' ) && ! empty( $attributes ) ) {
						
						foreach( $attributes as $attr ) {
							
							$key = str_replace( 'pa_', '', $attr->key );
							
							if( isset( $script_atts[ $key ] ) ) {
								$script_atts[ $key ] = $attr->value;
							}
							
						}
						
					}
			?>
				
				juapp(
					'orderItem',
					'<?php echo $item->get_ID(); ?>',
					<?php
						printf( '{name:\'%1$s\',quantity:\'%2$s\',price:\'%3$s\',color:\'%4$s\',size:\'%5$s\'}',
							$product->get_name(),
							$item->get_quantity(),
							$product->get_price(),
							$script_atts['color'],
							$script_atts['size']
						);
					?>
				);
				
			<?php endforeach; ?>
		
		</script>
		
	<?php
	
}
add_action( 'woocommerce_thankyou', 'jwt_woocommerce_thankyou_juapp_tracking' );
If need be I can add a link to download the code as a plugin ( which would be fully install-able as a plugin ).							
George Sprouse comments:
Thank you the worked out perfect!