<?php if (isset($order_id) && $order_id) { ?>
<!-- Google Analytics - Ecommerce Tracking (Universal Analytics) -->
<script type="text/javascript">
gtag('event', 'purchase', {
"transaction_id": "<?php echo $order_id; ?>",
"affiliation": "<?php echo $order_info['store_name']; ?>",
"value": <?php echo $order_info['total']; ?>,
"currency": "<?php echo $order_info['currency_code']; ?>",
"tax": "<?php echo $tax; ?>",
"shipping": "<?php echo $shipping; ?>",
"items": [
<?php foreach ($order_products as $row) { ?>
{
"id": "<?php echo $row['model']; ?>",
"name": "<?php echo $row['name']; ?>",
"quantity": <?php echo $row['quantity']; ?>,
"price": '<?php echo $row['price']; ?>'
},
<?php } ?>
]
});
</script>
<!-- End Google Analytics - Ecommerce Tracking (Universal Analytics) -->
<!-- Event snippet for Покупка товара conversion page -->
<script>
gtag('event', 'conversion', {
'send_to': 'Ваше из гугладвордса',
'value': <?php echo $order_info['total']; ?>,
'currency': '<?php echo $order_info['currency_code']; ?>',
'transaction_id': '<?php echo $order_id; ?>'
});
</script>
Верхнее для view файла success.tpl
ниже для контроллера success.php
if (isset($this->session->data['order_id'])) {
$this->load->model('account/order');
$this->data['order_id'] = $this->session->data['order_id'];
$this->data['order_info'] = $this->model_account_order->getOrder($this->session->data['order_id']);
$this->data['order_totals'] = $this->model_account_order->getOrderTotals($this->session->data['order_id']);
$this->data['order_products'] = $this->model_account_order->getOrderProducts($this->session->data['order_id']);
$shipping = 0;
foreach ($this->data['order_totals'] as $row)
{
if ($row['code'] == 'shipping')
{
$shipping = $row['value'];
}
}
$this->data['shipping'] = $shipping;
$tax = 0;
foreach ($this->data['order_products'] as $row)
{
$tax = $tax + $row['tax'];
}
$this->data['tax'] = $tax;
$this->cart->clear();
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['guest']);
unset($this->session->data['comment']);
unset($this->session->data['order_id']);
unset($this->session->data['coupon']);
unset($this->session->data['reward']);
unset($this->session->data['voucher']);
unset($this->session->data['vouchers']);
}