News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Tracking Virtuemart eCommerce Transactions in Google Analytics

Started by roger311, June 09, 2015, 16:08:01 PM

Previous topic - Next topic

roger311

Hi,

i am running eCommerce website in Virtuemart . Any one can guide me how to Tracking Virtuemart eCommerce  Transactions in Google Analytics.
I found below helping code
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce
http://joomla-tool-shop.com/tutorials/google-analytics-transaction-tracking-in-virtuemart
But i am confuse where these code i put in Virtuemart file structure.
Any other ways on which Virtuemart file structure i put the above link mention code  into the file that help me to Track Virtuemart eCommerce  Transactions in Google Analytics.

Thanks in Advance.
Roger

Dog_Guy

Hi -  I am searching for the very same thing.  I dont see why you need a joomla plugin, but they do apparently exists for this.  Also it would be very useful for an easy to find documentation on what VM or joomla page URL triggers the e-commerce info on GA.   That is what my developer is searching for right now.
You can buy healthy dog treats from either of my sites: http://www.dogwalkersmelbourne.com.au/ or http://www.healthydogtreats.com.au/

PRO


pinochico

Yes,

I use three years two free plugins from EasySoftware:

1. Google Tag Manager plugin for Joomla
2. E-commerce Virtuemart plugin for Google Tag Manager

You can setup custom variables for custom dimension and than tracking what do you want :)

http://www.easyjoomla.org/free-products/google-tag-manager
http://www.easyjoomla.org/free-products/google-e-commerce-tracker-for-virtuemart

Rudolf
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

FusionNetwork

Quote from: pinochico on April 04, 2017, 00:03:30 AM
Yes,

I use three years two free plugins from EasySoftware:

1. Google Tag Manager plugin for Joomla
2. E-commerce Virtuemart plugin for Google Tag Manager

You can setup custom variables for custom dimension and than tracking what do you want :)

http://www.easyjoomla.org/free-products/google-tag-manager
http://www.easyjoomla.org/free-products/google-e-commerce-tracker-for-virtuemart

Rudolf

Hi,

Can you help me with creating dataLayer end custom events in GTM?

Thanks
Cosmin

escozul

Quote from: roger311 on June 09, 2015, 16:08:01 PM
Hi,

i am running eCommerce website in Virtuemart . Any one can guide me how to Tracking Virtuemart eCommerce  Transactions in Google Analytics.
I found below helping code
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce
http://joomla-tool-shop.com/tutorials/google-analytics-transaction-tracking-in-virtuemart
But i am confuse where these code i put in Virtuemart file structure.
Any other ways on which Virtuemart file structure i put the above link mention code  into the file that help me to Track Virtuemart eCommerce  Transactions in Google Analytics.

Thanks in Advance.
Roger

Hello,

I've been trying to implement the instructions from here: http://joomla-tool-shop.com/tutorials/google-analytics-transaction-tracking-in-virtuemart in my VM3 order_done.php but I end up breaking it.

I believe that I'm missing something regarding the instructions there. You see I made the order_done.php file as so:
Quote<?php
/**
*---------------------------------------------------------------------------------------
* @package      VP One Page Checkout - Joomla! System Plugin
* @subpackage   For VirtueMart 3+
*---------------------------------------------------------------------------------------
* @copyright    Copyright (C) 2012-2017 VirtuePlanet Services LLP. All rights reserved.
* @license      GNU General Public License version 2 or later; see LICENSE.txt
* @authors      Abhishek Das
* @email        info@virtueplanet.com
* @link         https://www.virtueplanet.com
*---------------------------------------------------------------------------------------
* $Revision: 105 $
* $LastChangedDate: 2017-01-23 14:03:40 +0530 (Mon, 23 Jan 2017) $
* $Id: order_done.php 105 2017-01-23 08:33:40Z abhishekdas $
* --------------------------------------------------------------------------------------
*/
defined('_JEXEC') or die;

echo '<div class="vm-wrap vm-order-done">';

if($this->display_title)
{
   echo '<h3>' . vmText::_('COM_VIRTUEMART_CART_ORDERDONE_THANK_YOU') . '</h3>';
}

// Everything here is displayed by payment method plugin.
// It is exactly same as standard VirtueMart order done layout. We just need to print it as it is.
echo $this->html;

if(vRequest::getBool('display_loginform', true) && !JFactory::getUser()->guest && class_exists('shopFunctionsF'))
{
   echo shopFunctionsF::getLoginForm();
}

echo '</div>';
?>
<?php
   $q = "SELECT order_status, order_number, order_total, order_tax, order_shipping FROM #__{vm}_orders WHERE ";
   $q .= "#__{vm}_orders.user_id= " . $auth["user_id"] . " ";
   $q .= "AND #__{vm}_orders.order_id= $order_id ";

   $db->query($q);
   if ($db->next_record()) {
      $order_status = $db->f("order_status");
      $order_number = $db->f("order_number");
      $order_total = $db->f("order_total");
      $order_tax = $db->f("order_tax");
      $order_shipping = $db->f("order_shipping");
   }

   if($order_status == PAYPAL_VERIFIED_STATUS
   || $order_status == PAYPAL_PENDING_STATUS) {
      // Create a JavaScript string to add a transaction - use order number as the unique field.
      $myTagString = "

      <script type='text/javascript'>
      var _gaq = _gaq || [];
      _gaq.push(['_addTrans',
      '$order_number',           // order ID - required
      '24fit.gr Herbalife Store',        // affiliation or store name
      '$order_total',          // total - required
      '$order_tax',           // tax
      '$order_shipping',        // shipping
      '',                   // city
      '',                  // state or province
      ''                  // country
      <pre> ]);";

      // get multiple items here
      $q2 = "SELECT * FROM #__{vm}_order_item WHERE #__{vm}_order_item.order_id= $order_id";
      $db->query($q2);
      while ($db->next_record()) {
         $item_sku = $db->f("order_item_sku");
         $item_name = $db->f("order_item_name");
         $item_price = $db->f("product_final_price");
         $item_quantity = $db->f("product_quantity");
         $myTagString .= "
         _gaq.push(['_addItem',
         '$order_number',           // order ID - necessary to associate item with transaction
         '$item_sku',           // SKU/code - required
         '$item_name',        // product name
         '',   // category or variation
         '$item_price',          // unit price - required
         '$item_quantity'               // quantity - required
         ]);";
      }
      $myTagString .= "
      _gaq.push(['_trackTrans']);

      </script>
      ";

      $document = &JFactory::getDocument();
      $document->addCustomTag($myTagString);
      ?>
      <img src="<?php echo VM_THEMEURL ?>images/button_ok.png" align="middle"
      alt="<?php echo $VM_LANG->_('VM_CHECKOUT_SUCCESS'); ?>" border="0" />
      <h2><?php echo $VM_LANG->_('PHPSHOP_PAYPAL_THANKYOU') ?></h2>
   <?php
   }
   else { ?>
   <img src="<?php echo VM_THEMEURL ?>images/button_cancel.png" align="middle"
   alt="<?php echo $VM_LANG->_('VM_CHECKOUT_FAILURE'); ?>" border="0" />

   <?php echo $VM_LANG->_('PHPSHOP_PAYPAL_ERROR') ?>
   <?php
   }
?>

I don't know but I think that there are the following issues on the code I managed to create off from that website:
1. it seems that it only should work for Paypal? So we need to change the code so that it works for all payment methods.
2. Maybe that suggestion was written a long time ago and since the variable names and class names have changed. Could someone help me figuring out the proper class name?

I'd appreciate all the help I can get to get the transaction tracking for google analytics working. And we can post here complete solution for the people coming next

Thank you