Skip to content

Commit

Permalink
coreshop#1613 TagManagerEnhancedEcommerce
Browse files Browse the repository at this point in the history
fixing some of the listed issues in the ticket
Fixed:
- trackCheckoutComplete - Rename total to revenue
- trackProductImpression - remove quantity, brand, position, attribute
- trackCartAdd - quantity is hardcoded to 1. Use $quantity instead

Template issues
- product_impression.js.twig
- product_view.js.twig
- checkout.js.twig
- checkout_complete.js.twig

Not fixed:
- trackProductImpression - submit impression as multi- instead of single-array
- trackCartAdd - price attribute: I'm not sure about that but I think we need to use the cart item price instead of product price (which often can't be determinate (because of complex variant structure etc.)
- trackCartRemove
  • Loading branch information
JustMe69 committed Jun 24, 2022
1 parent b70585a commit e0a125a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dataLayer.push({ 'event': 'csCheckout', 'checkout': {{ actionData|json_encode()|raw }} });
dataLayer.push({'event': 'csCheckout', 'ecommerce': {'checkout': {{ actionData|json_encode()|raw }} }});
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dataLayer.push({'ecommerce' : { 'purchase' : {{ actionData|json_encode()|raw }} } });
dataLayer.push({'event': 'csPurchase', 'ecommerce' : { 'purchase' : {{ actionData|json_encode()|raw }} } });
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dataLayer.push({'ecommerce' : {{ actionData|json_encode()|raw }} });
dataLayer.push({'event': 'csProductImpressions', 'ecommerce' : {{ actionData|json_encode()|raw }} });
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dataLayer.push({'ecommerce': {'detail': {{ actionData|json_encode()|raw }} }});
dataLayer.push({'event': 'csProductDetailImpressions', 'ecommerce': {'detail': {{ actionData|json_encode()|raw }} }});
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function trackCartAction($product, $action, $quantity = 1): void
{
$this->ensureDataLayer();

$product['quantity'] = 1;
$product['quantity'] = $quantity;

$actionData = [$action => []];

Expand All @@ -177,7 +177,7 @@ protected function transformOrder($actionData): array
return [
'id' => $actionData['id'],
'affiliation' => $actionData['affiliation'] ?: '',
'total' => $actionData['total'],
'revenue' => $actionData['total'],
'tax' => $actionData['totalTax'],
'shipping' => $actionData['shipping'],
'currency' => $actionData['currency'],
Expand All @@ -190,11 +190,7 @@ protected function transformProductAction($item): array
'id' => $item['id'],
'name' => $item['name'],
'category' => $item['category'],
'brand' => $item['brand'],
'variant' => $item['variant'],
'price' => round($item['price'], 2),
'quantity' => $item['quantity'] ?: 1,
'list_position' => $item['position'],
]);
}

Expand Down

0 comments on commit e0a125a

Please sign in to comment.