Commit 8dde2442dba1848e37ec49c6545d107d9926c836
1 parent
42d9e5c3
Google ecommerce
Showing
1 changed file
with
28 additions
and
1 deletions
Show diff stats
frontend/views/order/success.php
| @@ -49,7 +49,34 @@ | @@ -49,7 +49,34 @@ | ||
| 49 | <a href="/" style="display:inline">« На главную</a> | 49 | <a href="/" style="display:inline">« На главную</a> |
| 50 | </div> | 50 | </div> |
| 51 | <!-- Google ECommerce Code --> | 51 | <!-- Google ECommerce Code --> |
| 52 | - | 52 | + <script> |
| 53 | + ga('require', 'ecommerce'); | ||
| 54 | + <?php | ||
| 55 | + $sum = 0; | ||
| 56 | + foreach ($variants as $product) { | ||
| 57 | + ?> | ||
| 58 | + ga( | ||
| 59 | + 'ecommerce:addItem', { | ||
| 60 | + 'id': '<?= $order->id; ?>', | ||
| 61 | + 'name': '<?= $product['product_name']; ?>', | ||
| 62 | + 'price': '<?= $product['price']; ?>', | ||
| 63 | + 'sku': '<?= $product['sku']; ?>', | ||
| 64 | + 'quantity': '<?= $product['quantity']; ?>' | ||
| 65 | + } | ||
| 66 | + ); | ||
| 67 | + <?php | ||
| 68 | + $sum += $product['sum_cost']; | ||
| 69 | + } | ||
| 70 | + ?> | ||
| 71 | + ga( | ||
| 72 | + 'ecommerce:addTransaction', { | ||
| 73 | + 'id': '<?= $order->id; ?>', | ||
| 74 | + 'affiliation': 'www.linija-svitla.ua', | ||
| 75 | + 'revenue': '<?= $sum; ?>', | ||
| 76 | + } | ||
| 77 | + ); | ||
| 78 | + ga('ecommerce:send'); | ||
| 79 | + </script> | ||
| 53 | </td> | 80 | </td> |
| 54 | </tr> | 81 | </tr> |
| 55 | </tbody> | 82 | </tbody> |