Posted on 08/03/2022 09:03:56
HI just recenty cam upon this and there are three things:
1. The duplication from the email link:
Solution: On the bottomsnippets include the following condition on whether to call the GTM code ( and facebook):
@GetDouble("Ecom:Order.ReceiptShowCount") <= 1
Full context example:
@{
if (!string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID")) && @GetDouble("Ecom:Order.ReceiptShowCount") <= 1)
{
snippetsPage.Add("OrderContainer", new Block
{
Id = "FacebookPixelEvent",
SortId = 100,
Template = RenderFacebookPixelEvent()
});
}
if (!string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")) && @GetDouble("Ecom:Order.ReceiptShowCount") <= 1)
{
snippetsPage.Add("OrderContainer", new Block
{
Id = "GoogleTagManagerEvent",
SortId = 110,
Template = RenderGoogleTagManagerEvent()
});
}
2. We have an issue in that the dw code does not distinguish from discount line items - so it renders all the product lines as products in GTM.
Solution: Separated the discounts and products into two lists and then for each product I searched the discount list for a discount and if found applied the discount to the product and added the "coupon" tag to the GTM product item.
I can provide example if you wish.
3. Amount formatting. Depending on the culture settings the format had a comma as the decimal separator ( 100,00).
Solution: GTM doesn't like this, so I formatted to string and replaced the comma with a period.