Post by countzer0 » Wed Nov 23, 2011 4:37 am

Kim_A wrote:Should i remove the normal tracking code if i use this mod?
No, all this mod does is to place a special Google Analytics tracking tag on the checkout completion page which passes the value of the transaction and the order details to the GA servers. This allows GA to calculate conversion data, for example to see the revenue from an AdWords campaign.

You will still need to leave the standard GA tag enabled in OpenCart.

A happy OpenCart developer from Brighton.


User avatar
New member

Posts

Joined
Sat Jun 18, 2011 11:09 pm
Location - Brighton, UK

Post by Concept211 » Thu Jan 05, 2012 5:32 am

countzer0: You had a very slight error in the code that was throwing a PHP error when loading the "success" page after checkout. It's been fixed (see attached).

Also posted in the extensions repository for everyone's convenience:
http://www.opencart.com/index.php?route ... on_id=4511

Thanks for your help!

Attachments


User avatar
New member

Posts

Joined
Fri Oct 14, 2011 1:40 am

Post by countzer0 » Thu Jan 05, 2012 5:13 pm

Concept211 - thanks so much! This was driving me nuts as the error only seemed to happen on the live success page, not the test. Well done for spotting it.

A happy OpenCart developer from Brighton.


User avatar
New member

Posts

Joined
Sat Jun 18, 2011 11:09 pm
Location - Brighton, UK

Post by bendy00123 » Fri Jan 06, 2012 12:56 am

hello

for the VQmod, step 7 : Make sure that you have "E-Commerce Tracking" turned on in your Google Analytics account.

where do i find this ? im unable to find it when im at the dashboard, serached for 1/2hr now..

New member

Posts

Joined
Wed Oct 12, 2011 7:30 am

Post by countzer0 » Fri Jan 06, 2012 1:16 am

Searching GA Help Centre for "e-commerce tracking" gives this as the first result: http://support.google.com/analytics/bin ... er=1009612

A happy OpenCart developer from Brighton.


User avatar
New member

Posts

Joined
Sat Jun 18, 2011 11:09 pm
Location - Brighton, UK

Post by spitos » Tue Jan 10, 2012 12:31 am

For anyone wanting comprehensive tracking with google analytics that just works and is easy to setup, with full instructions and free support. Checkout Google Analytics Expert:
http://www.opencart.com/index.php?route ... on_id=4496

Features:
E-Commerce Tracking, Goal & Funnel Reporting, Event Tracking, Search Tracking, support for Google Adwords, Multi-Store compatibility, EU Cookie Law compliance & more in a vqmod script.

Full E-commerce & Order tracking - See which products were ordered with data for Model/SKU, Product Name, Quantity, Product Price.

Full Product & Product Options Tracking and Reporting including Product Category, Shipping Costs & Taxes.

Also compatible with the popular Shoppica & Shoppica 2 themes & Bingo's popular one step / one page checkout extensions.
Last edited by spitos on Fri Jun 22, 2012 8:59 pm, edited 3 times in total.

Image
Google Analytics Expert - Advanced e-commerce tracking, Product & options reporting, transaction/conversion reporting, Google Adwords conversion & profit reporting, goal & funnel reporting, event tracking, site search tracking, multi-store compatibility, EU Cookie Law compliance and works with any theme or checkout! Easy vqmod install. Get it here


User avatar
Active Member

Posts

Joined
Mon May 23, 2011 6:19 pm
Location - UK

Post by countzer0 » Thu Jan 19, 2012 8:19 pm

I _still_ cannot get this vQmod to work. Looking in the xml file, the vQmod makes changes to the following files:

catalog/controller/checkout/success.php
catalog/model/checkout/order.php
catalog/view/theme/default/template/common/success.tpl

Looking in my vqcache folder, I can find the following cached modified scripts:

vq2-catalog_model_checkout_order.php
vq2-catalog_view_theme_default_template_common_success.tpl

but there is no vq2-catalog_controller_checkout_success.php. Does this mean that the mods to catalog/controller/checkout/success.php are not being made? There are no errors in my vQmod error log.

I'd appreciate any help.

A happy OpenCart developer from Brighton.


User avatar
New member

Posts

Joined
Sat Jun 18, 2011 11:09 pm
Location - Brighton, UK

Post by nikythebest » Fri Mar 02, 2012 8:27 pm

I installed module but it seems something is wrong. Is no tracking all the transactions. Is missing some of my transactions. Anyone know why?

New member

Posts

Joined
Thu Sep 15, 2011 3:54 am

Post by Concept211 » Fri Mar 02, 2012 9:22 pm

Hey all,

For some reason it looks like this isn't working properly. I'm not the creator of the code, I simply converted it to a vQmod but it looks like the original code isn't tracking any sales. If anyone has a fix, please post it so that we can update the vQmod and allow everyone to use it.

thanks!

User avatar
New member

Posts

Joined
Fri Oct 14, 2011 1:40 am

Post by theking1010 » Mon Mar 05, 2012 1:58 am

Hi, I have PayPal as my only form of payment. When the customer purchases the item, the customer leaves the Paypal site and does not click go back to the Store site, where the store site GA code is on the success.tpl page, and then triggers the transaction data capture in GA.

How can this issue be fixed to where the GA transaction data is captured if the customer does not click on the link on PayPal to return to the Store site?

Thanks!
Elvis

Newbie

Posts

Joined
Tue Nov 15, 2011 11:12 pm

Post by designbuyers » Mon Mar 05, 2012 5:36 am

Is this method work with 1.5.2.1 ?

OpenCart :
The best Open Source Cart for eCommerce


User avatar
Active Member

Posts

Joined
Tue Nov 09, 2010 4:25 pm

Post by theking1010 » Tue Mar 06, 2012 9:02 pm

I am running version 1.5.1.3. Can you help?

Newbie

Posts

Joined
Tue Nov 15, 2011 11:12 pm

Post by marcelwoo » Wed Mar 07, 2012 11:39 am

Thanks! works like a charm!
Here:

Code: Select all

   <?php foreach($orderProducts as $product) { ?>
      _gaq.push(['_addItem',
          "<?php echo $product['order_id']; ?>",
          "<?php echo $product['product_id']; ?>",
          <?php echo json_encode($product['name']); ?>,
          "<?php echo $product['model']; ?>",
          "<?php echo $product['price']+($product['price']*$product['tax']/100); ?>",
          "<?php echo $product['quantity']; ?>"
       ]);
   <? } ?>
If I want to change $product['modle'] to category name (not category id), how should I do it? thx

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by moneycarlo » Tue May 01, 2012 12:09 pm

I updated to 1.5.2.2(r990) and added the missing fields like tax, shipping info etc.
I also changed the way the product price was being calculated. The numbers never came out correctly for my use and just seemed odd.
The old calculation was (i suspect they meant the price was supposed to be multiplied by the tax rate and not the actual tax?):
$product['price']+($product['price']*$product['tax']/100)

I changed it to:
$product['price']+$product['tax'];

Now, I'm no php/sql expert so the way i did it may not be the most efficient or proper, but what I do know, is that's working fine for me.
I cant promise I can answer any issues but will try.
Thanks!

** Sorry, there's a couple bugs I need to fix so I pulled the mod. Will re-up when I correct. Thanks and sorry **
Last edited by moneycarlo on Fri May 11, 2012 11:51 pm, edited 1 time in total.

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by Concept211 » Tue May 01, 2012 8:12 pm

Thanks moneycarlo!

User avatar
New member

Posts

Joined
Fri Oct 14, 2011 1:40 am

Post by stonehinged » Tue May 08, 2012 3:03 am

Moneycarlo, the tracking code is not rendering when I view the source on the success page using your vQmod.

Code: Select all

<?php if(isset($orderDetails) && isset($orderProducts) && isset($orderShipping) && isset($orderTax)) { ?>

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
  _gaq.push(['_addTrans',
    '<?php echo $orderDetails['order_id']; ?>',
    'STORE NAME',
    '<?php echo $orderDetails['total']; ?>',
    '<?php echo $orderTax[0]['value']; ?>',
    '<?php echo $orderShipping[0]['value']; ?>',
    '<?php echo $orderDetails['shipping_city']; ?>',
    '<?php echo $orderDetails['shipping_zone']; ?>',
    '<?php echo $orderDetails['shipping_country']; ?>'
   ]);

   <?php foreach($orderProducts as $product) { ?>
      _gaq.push(['_addItem',
          "<?php echo $product['order_id']; ?>",
          "<?php echo $product['product_id']; ?>",
          <?php echo json_encode($product['name']); ?>,
          "<?php echo $product['model']; ?>",
          "<?php echo $product['price']+$product['tax']; ?>",
          "<?php echo $product['quantity']; ?>"
       ]);
   <?php } ?>
   
   _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<?php } ?>
Let me add the obvious... I have replaced the setAccount variable with mine ;D
Last edited by stonehinged on Tue May 08, 2012 11:48 pm, edited 1 time in total.

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by Svpernova09 » Tue May 08, 2012 9:42 pm

I've followed the instructions in the original post and I'm getting this error when I view source on the success page:

Code: Select all

<b>Notice</b>: Undefined variable: orderstuff in <b>catalog/view/theme/default/template/common/success.tpl</b> on line <b>5
The confusing part is line 5 seems meaningless. it's a comment of a JavaScript.

I've tried adding this code:

Code: Select all

<?php echo("<pre>"); print_r($orderstuff); echo("</pre>");
$thistotal = $orderstuff['total'];
echo("thistotal: $thistotal<BR>"); 
$thisorderid = $orderstuff['order_id'];
echo("thisorderid: $thisorderid<BR>"); 
?>
And it runs and shows the correct variables. But the fields are blank when I view the source.
OpenCart Version 1.5.1.3
catalog/controller/checkout/success.php

Code: Select all

	public function index() { 
		if (isset($this->session->data['order_id'])) {
			$this->load->model('checkout/order');
			$this->data['orderDetails'] = $this->model_checkout_order->getOrder($this->session->data['order_id']);
			$this->data['orderProducts'] = $this->model_checkout_order->getOrderProducts($this->session->data['order_id']);
			$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']);
		}	
catalog/model/checkout/order.php

Code: Select all

public function getOrderProducts($order_id) {
    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");

            return $query->rows;
        }  
Any help would be appreciated.

Newbie

Posts

Joined
Tue May 08, 2012 9:07 pm

Post by moneycarlo » Wed May 09, 2012 6:15 am

stonehinged wrote:Moneycarlo, the tracking code is not rendering when I view the source on the success page using your vQmod.

Code: Select all

<?php if(isset($orderDetails) && isset($orderProducts) && isset($orderShipping) && isset($orderTax)) { ?>

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
  _gaq.push(['_addTrans',
    '<?php echo $orderDetails['order_id']; ?>',
    'STORE NAME',
    '<?php echo $orderDetails['total']; ?>',
    '<?php echo $orderTax[0]['value']; ?>',
    '<?php echo $orderShipping[0]['value']; ?>',
    '<?php echo $orderDetails['shipping_city']; ?>',
    '<?php echo $orderDetails['shipping_zone']; ?>',
    '<?php echo $orderDetails['shipping_country']; ?>'
   ]);

   <?php foreach($orderProducts as $product) { ?>
      _gaq.push(['_addItem',
          "<?php echo $product['order_id']; ?>",
          "<?php echo $product['product_id']; ?>",
          <?php echo json_encode($product['name']); ?>,
          "<?php echo $product['model']; ?>",
          "<?php echo $product['price']+$product['tax']; ?>",
          "<?php echo $product['quantity']; ?>"
       ]);
   <?php } ?>
   
   _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<?php } ?>
Let me add the obvious... I have replaced the setAccount variable with mine ;D
Did you check your google account? Mine doesn't show it in the source either, but I use a proxy tool to see the values being sent. You can see this using something like firebug.

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by moneycarlo » Wed May 09, 2012 6:28 am

I don't know what orderstuff is. I never created or used that so I have no idea where that came from..you'll have to figure that out. Maybe it needs an isset?
comment it out and see what happens? Did you look at your google data or use a tool like firebug to see if the results posted?

Also, this could be an issue with 1.5.1.3 vs 1.5.2.2. I know a part of the order.php file was changed between these versions. I believe the addOrder was the change in 1.5.2.2:
public function addOrder($data)

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by moneycarlo » Wed May 09, 2012 6:35 am

I think if one changes my script it could work with 1.5.1.3:
change:
public function addOrder($data)

to:
public function create($data)

And i THINK that should work. no promises though since i'm no longer on that version, so someone can test it out and report back.

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am
Who is online

Users browsing this forum: No registered users and 15 guests