Developer forum

Forum » Swift » GA events using culture aware values

GA events using culture aware values

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

It seems that the gtag code for Swift uses default (currency) formatting which breaks standard JavaScript. For example, on one site I have, this code:

 <script>
 gtag("event", "begin_checkout", {
 currency: "@GetString("Ecom:Order.CurrencyCode")",
 value: @GetString("Ecom:Order.Price.Price.Value"),
 items: [
 @foreach (LoopItem orderline in GetLoop("OrderLines")) {
 <text>
 {
 item_id: "@orderline.GetString("Ecom:Order:OrderLine.ProductID")",
 item_name: "@orderline.GetString("Ecom:Order:OrderLine.ProductName")",
 currency: "@orderline.GetString("Ecom:Order:OrderLine.UnitPrice.CurrencyCode")",
 price: @orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.Price.Value"),
 quantity: "@orderline.GetString("Ecom:Order:OrderLine.Quantity")" 
 },
 </text>
 }
 ]
 });
 </script>
 
renders output like this:
<script>
  gtag("event", "begin_checkout", {
    currency: "EUR",
    value: 13,85,
    items: [
        {
          item_id: "6722330",
          item_name: "Some name",
          currency: "EUR",
          price: 8,9,
          quantity: "1"
        },
    ]
  });
</script>
The value and price result in invalid decimals, causing the browser to throw exceptions. This then causes other JavaScript on the page to fail as well.
 
Can this be fixed?
Thanks!

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Imar

This has actually been fixed in later versions, i.e:

https://github.com/dynamicweb/Swift/blob/main/Swift/Files/Templates/Designs/Swift/eCom7/CartV2/Step/InformationAnonymous_v2.cshtml#L63

I just found one missing place - making a pull now!

Thanks, Nicolai

Votes for this answer: 1

 

You must be logged in to post in the forum