View Single Post
  #3  
Old 04-08-2022, 10:29 AM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Man
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 2,963
 

Default Re: Setting up Data Layer for Ecom tracking in GA4

yeah I agree on the missing end foreach
Should be like this:
Code:
<script> window.dataLayer = window.dataLayer || []; dataLayer.push({ {foreach from=$orders item="order"} 'transactionId' : "{$order.order.orderid}", // order ID - required 'transactionAffiliation' : "{$partner|default:'Main stock'}", // affiliation or store name 'transactionTotal' : "{$order.order.total}", // total - required 'transactionShipping' : "{$order.order.shipping_cost}", // shipping 'transactionTax' : "{$order.order.tax}" // tax 'transactionProducts' : [{ {foreach from=$order.products item="product"} 'transactionId' : "{$order.order.orderid}", // order ID - required 'name' : "{$product.product|wm_remove|escape:javascript}{if $active_modules.Product_Options ne "" and $product.product_options_txt} ({$product.product_options_txt|replace:"\n":", "|wm_remove|escape:javascript}){/if}", // product name 'sku' : "{$product.productcode|wm_remove|escape:javascript}", // SKU/code - required 'category' : "{$product.category|default:'Unknown category'}", // category or variation 'price' : "{$product.price}", // unit price - required 'quantity' : "{$product.amount}" // quantity - required {/foreach} }] {/foreach} }); </script>
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote