Google Ecommerce Tracking errors

Please post your issues and questions about One Page Checkout for Virtuemart 2 to this forum.

Google Ecommerce Tracking errors

Postby info@.....cz » Fri May 23, 2014 2:25 pm

Hello Stan,
first let me appreciate your hard work, despite the fact that I work with around 30 extensions each week, this is the most awesome one - it spared me so much time.

I just have a little problem with the way how is Google Ecommerce Tracking implemented in OPC. I know it's exactly how Google says in its guide, but their guide is a little bit outdated.
Have a look at these two pictures, the left one is with your current version and the right one after replacing a deprecated method. Both of them are just a screenshot of Google Tag Assistent (Chrome addon to check Google tags).
Image

You can see some suggestions. I did what they suggested, replaced _getTracker() method with _createTracker() and right away it's a little bit better. Please, update the deprecated _getTracker() method with _createTracker().

Also note the suggestion about code position - why didn't you put the general Google tracking code (I don't mean the ecommerce tracking) to the head as proposed? I'm sure you have reasons for that.
It would be perfect if Google tag assistant showed no warnings at all :)

Thank you!
info@.....cz
 
Posts: 21
Joined: Thu Sep 26, 2013 11:08 pm

Re: Google Ecommerce Tracking errors

Postby info@.....cz » Fri May 23, 2014 4:26 pm

By the way, I have just found out that there is something wrong with pinging the GA account - it always pings it twice, once with empty values and once with already correct values.

The following code
Code: Select all
<script type="text/javascript">
/* <![CDATA[ */
var ping_url = 'http://dev.webeshop.cz/index.php?option=com_onepage&task=ping&nosef=1&format=raw&tmpl=component';
var ping_data = 'hash=opc537f00560e7b66.25687566&order_status=U&order_id=49&file=analytics';
opc_pingDone(ping_url, ping_data);
/* ]]> */
</script>

Is at the end of the /body tag, but it's not only after the Ecommerce script (analytics.php), but also right before it. (therefore, it's 2x in the code and it pings Google 2x as well)

Am I doing something wrong or is it some kind of bug? Thank you
info@.....cz
 
Posts: 21
Joined: Thu Sep 26, 2013 11:08 pm

Re: Google Ecommerce Tracking errors

Postby admin » Fri May 23, 2014 5:48 pm

hello, thank for your appreciation and for your feedback

1. yes, we will test the new async code but the reason we decided to use the sync code is that otherwise it would not be possible to detect errors within the code. also it's not clear if the async code gets executed especially if any other part of your site gives an error after our code is rendered. we decided to use the "sync" code only because it's more accurate comparing to the async code which may not get even executed and nobody would know

2. the ping gets executed before and after the code is run (the url is the same, but the post data are different). first says opc that the code execution was started, and the second says that no javascript error occurred and thus the code is considered as executed and will not get executed second time. If the tracking code gives an error, opc will try to executed until it runs without an error (with a few security limits on this - max 5 orders, max 1 month from the purchase). this is also reason why we decided to use the "sync" code.

i believe it's not proper to call the old code "deprecated", it's only a way of the execution of the script (whether to call it on "on dom ready", which may not even occur, or to call it when it is printed) - due to accurancy we decided for the second solution. Note, that "on dom ready, i.e. async code" is excuted after all your live chat buttons, images, iframes, fb like buttons, etc... are loaded.

best regards,
stan, rupostel.com
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Google Ecommerce Tracking errors

Postby info@.....cz » Wed May 28, 2014 9:34 pm

Thank you for your explanation.

Sorry for not expressing myself correctly, I didn't mean that synchronized javascript is deprecated, only the function _getTracker() is deprecated, it's been replaced with _createTracker() even in Google docs.


I'm still struggling with a little detail which is actually a huge problem for correct analyses. Look at this Google Analytics screenshot below:
Image

You can see
- 5 transactions, 3 unique purchases and quantity 3 - that should mean that there has been 5 orders done which include 3 different products. But there goes the quantity and it stops making sense - you can't have 3 items bought altogether in 5 orders, that would mean that at least 2 orders were empty.
- the problem is not quantity, it's number of transactions - it states 5, but I did only 2. In the first order, I bought 1 T-Shirt and 1 Hat (2 items - quantity, 2 unique purchases), but it gave me 3 transactions into Google Analytics instead of one. So I created another order in my test shop, bought just one T-Shirt and ordered it. Into Google Analytics, 1 unique purchase has been added, 1 quantity added but also 2 transactions were added instead of 1.

Briefly once more
- Analytics were empty, then I made 2 orders.
- 1st order: 2 different items bought. Analytics showed 3 transactions, 2 unique purchases and quantity of 2.
- 2nd order: 1 item bought. Analytics showed 3+2 transactions, 2+1 unique purchases and quantity of 2+1.
=> number of transactions is wrong.

Do you have an idea what could be wrong? I checked your analytics.php code properly and it seems to be alright, but the number of transactions is definitely wrong and I have no idea how is that possible.
info@.....cz
 
Posts: 21
Joined: Thu Sep 26, 2013 11:08 pm

Re: Google Ecommerce Tracking errors

Postby admin » Sat May 31, 2014 1:31 pm

hello, pls make sure tha that the tracking is enabled just once per all the tabs of the available order statuses shown here:
Image

it's not recommended to use the pending status because that is the only one that is always used even when disabled globally in virtuemart. therefore it's recommended to set up your payment methods to use a resulting status such as "confirmed" or "confirmed by shopper" which would trigger the tracking.

even if you update the status from the backend to confirmed, the code will be executed once your customer returns to your site.

the code sends the unique ORDER_ID to the GA, so there should not be any duplicities in GA even when the script gets exectued twice.

secondly, if you are using payment plugins which instead of changing order status, delete an order after a failed payment you may see more orders made per the pending status in GA then you can find in your Virtuemart.

best regards,
stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Google Ecommerce Tracking errors

Postby admin » Sat May 31, 2014 1:33 pm

hello, further, pls check which orders got logged by google by visting this section:

Image

the above screenshot is from OPC1, in OPC2 you should see purely your order_ids

best regards,
stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Google Ecommerce Tracking errors

Postby info@.....cz » Sat May 31, 2014 8:36 pm

Hello,
because it did not work the way I wanted and because I will need to set custom goals anyway, I did my custom implementation of Google Ecommerce Tracking.
During it, I've figured out what's the problem in your code.

Look at your your foreach:
Code: Select all
   pageTracker._addItem(
      "<?php echo $order_item->virtuemart_product_id; ?>",           // transaction ID - necessary to associate item with transaction
      "<?php echo $this->escapeDouble($order_item->order_item_sku); ?>",           // SKU/code - required
      "<?php echo $this->escapeDouble($order_item->order_item_name); ?>",        // product name
      "<?php echo $this->escapeDouble($order_item->category_name ); ?>",   // category or variation
      "<?php echo number_format($order_item->product_final_price, 2, '.', ''); ?>",          // unit price - required
      "<?php echo number_format($order_item->product_quantity , 0, '.', ''); ?>"               // quantity - required
   );


In my opinion, according to what Google shows in their code and comments,
the problem is the transaction ID for each item.

Code: Select all
"<?php echo $order_item->virtuemart_product_id; ?>",           // transaction ID - necessary to associate item with transaction

This piece of your code will echo the product id, but that's wrong - you don't need the item id. You need the transaction (order) id. Therefore, you can repeate what you have in the _addTrans part:


Code: Select all
"<?php echo $this->order['details']['BT']->virtuemart_order_id; ?>",            // transaction ID - required

After changing it to this, each item of an order should be associated with only one order it belongs to.


I hope I'm right, didn't get to test it yet.
info@.....cz
 
Posts: 21
Joined: Thu Sep 26, 2013 11:08 pm

Re: Google Ecommerce Tracking errors

Postby admin » Mon Jun 02, 2014 2:14 pm

hello, thank you very much for reporting this, i am going to fix it straith away. will be available in the next release 245+

do you think we should add a new "custom GA goal" plugin?

to create a new plugin, just rename the php file + it's manifes, set it's name and description in the manifest and enable it within the backend.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Google Ecommerce Tracking errors

Postby info@.....cz » Mon Jun 02, 2014 3:57 pm

You're welcome, glad to help to make a good product even better :)

Such plugin would be good, but I'm not sure if you can create it so that it would provide all possible options that people may set as their goal.
But if you managed to set basic ones (added products to cart but never visited cart; visited cart but did not proceeed to order the items; ordered), it would be a nice feature, though I don't know how to do that yet. But I will have to figure it out at work soon anyway.
info@.....cz
 
Posts: 21
Joined: Thu Sep 26, 2013 11:08 pm

Re: Google Ecommerce Tracking errors

Postby admin » Mon Jun 02, 2014 4:16 pm

hello, actually we already have the custom work for abandoned carts ordered together with the GA tracking, so this will get included very soon.

further we want to extend the tracking features into:
- code execution only if the entry site referal matches a certain domain (example - the code for heureka will get executed only if an customer comes from heureka.cz) - we would like to use crossbrowser flash cookies for this
- add more options to execute the code: "on referal" "on cart visit" "on order per payment and per status" -> right now it's only per status regarless of the payment selected

this should be done in following weeks.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 2