Web Analytics for e commerce

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
1 week 6 days ago #305734

Hello

I want to track this analytics code for e commerce report when the customer has finished the chekout.

<script language='javascript'>;
gtag('event', 'purchase', { 'event_category' : 'ecommerce', 'event_label' : <?php $row->product_name ?> });
</script>;

My Question are:

Where can i put the script (file xxx.php,) ?

I want to track the product name of my shop, i dont know if ($row->product_name) is right varible that i must use it.
I hope your news

Kind Regads.

Please Log in or Create an account to join the conversation.

  • Posts: 65411
  • Thank you received: 9529
  • MODERATOR
1 week 5 days ago #305736

Hi,

You can add that code in the file "after_end" of the view "checkout" via the menu Display>Views provided that you didn't enter a "return URL" in your payment method and that your payment method redirects you to the payment gateway at the end of the checkout for the payment.
If it's not the case, then you'll want to add the code int he file "end" of the view "checkout".
In both cases, you can find the products in the order in the array $this->order->products since you can have several products. So your code will have to be something like that:

<script language='javascript'>
<?php foreach( $this->order->products as $row) { ?>
gtag('event', 'purchase', { 'event_category' : 'ecommerce', 'event_label' : '<?php echo $row->order_product_name; ?>' });
<?php }  ?>
</script>

Please Log in or Create an account to join the conversation.

Time to create page: 0.053 seconds
Powered by Kunena Forum