Ecommerce - Problem with Items in cart and abandoned carts

Howdy,
i’m using Piwik since 0.6 - great work guys!
Now i’m able to track eCommerce Actions Piwik - very cool!

  • There seems to be a Problem when tracking items added/removed to/from cart: Every time the cart-content changes (item add/removed/change quantity) the visitor is “splitted” into 2 or more visitors (screenshot from visitors log attached).

  • Its the same if an order is placed - i get succesfull order with the orderd items - but there stays an abandoned cart from another visitor with the same items…

Here’s the code from Cart.php - smarty template:


{* SHOPPING CART *}
{if $smarty.server.SCRIPT_FILENAME|basename == "Cart.php" and $hasCart eq TRUE}
// shoppingCart
{foreach from=$productsInCart item=product}
piwikTracker.addEcommerceItem("{$product.id} [{$product.selectedSize}]", "{$product.brand}, {$product.name} [{$product.selectedSize}]", "", parseFloat({$product.price|replace:',':'.'}), parseFloat({$product.selectedAmount}));
{/foreach}
piwikTracker.trackEcommerceCartUpdate(parseFloat({$cartValue|replace:',':'.'}));
{/if}

Here’s the code from Checkout-Thankyou.php - smarty template:


{* CHECKOUT THANKYOU *}
{if $smarty.server.SCRIPT_FILENAME|basename == "Checkout-Thankyou.php" and !empty($o_data) and !empty($o_items)}
// checkout Thankyou
// piwikTracker.trackGoal( 1, {$o_total} );
{foreach from=$o_items item=product}
piwikTracker.addEcommerceItem("{$product.id} [{$product.selectedSize}]", "{$product.name} [{$product.selectedSize}]", "", parseFloat({$product.price|replace:',':'.'}), parseFloat({$product.quant}));
{/foreach}
piwikTracker.trackEcommerceOrder("{$o_data.order_id}", parseFloat({$o_total}), parseFloat({$o_subtotal}), 0, parseFloat({$o_data.ship_cost}), false);
{/if}

Anyone with same Problem?

Best regard from Germany!
– wit

P.S. ip of the two visitors in the screenshot ist the same

well yeah I had a website that doesnt matter how someone ordered they it never went through.

Orders are tracked correctly - but an abandoned cart with the same items as in the order persists too… :’(

wit, that’s indeed quite a problem. But, maybe IPs are changing for these users?

Can you put here the output of piwik_log_visit for the 2 visits row pairs that should have been 1 visit?Thanks

Hi, matt,
thanks for your answer.

I’m sure they are not, see attached screenshot.

This problem happens every time a visitor visits the cart - screenshot attached is from today - 1 visitor getting 4 visitors… - can’t find the visit from yesterdays example any more…

Heres output grabbed from db regarding the visitor from the screenshot (query: SELECT * FROM piwik_log_visit WHERE idsite = 15 AND config_resolution LIKE ‘1600x900’ AND config_browser_name = ‘FF’ AND config_browser_version = ‘4.0’ AND visit_first_action_time BETWEEN ‘2011-06-22 10:00:00’ AND ‘2011-06-22 11:00:00’ ORDER BY visit_first_action_time DESC)


<?xml version="1.0" encoding="utf-8" ?>
<!--
-
- phpMyAdmin XML Dump
- version 2.11.8.1deb5+lenny8
- http://www.phpmyadmin.net
-
- Host: localhost
- Erstellungszeit: 22. Juni 2011 um 14:05
- Server Version: 5.0.51
- PHP-Version: 5.2.6-1+lenny10
-->

<!--
- Datenbank: 'my_db_name'
-->
<analytics_mediatac_net>
  <!-- Tabelle piwik_log_visit -->
    <piwik_log_visit>
        <idvisit>700292</idvisit>
        <idsite>15</idsite>
        <idvisitor>órٍó¹ </idvisitor>
        <visitor_localtime>12:47:38</visitor_localtime>
        <visitor_returning>1</visitor_returning>
        <visitor_count_visits>6</visitor_count_visits>
        <visit_first_action_time>2011-06-22 10:47:54</visit_first_action_time>
        <visit_last_action_time>2011-06-22 10:50:21</visit_last_action_time>
        <visit_exit_idaction_url>202805</visit_exit_idaction_url>
        <visit_exit_idaction_name>197631</visit_exit_idaction_name>
        <visit_entry_idaction_url>0</visit_entry_idaction_url>
        <visit_entry_idaction_name>0</visit_entry_idaction_name>
        <visit_total_actions>5</visit_total_actions>
        <visit_total_time>147</visit_total_time>
        <visit_goal_converted>1</visit_goal_converted>
        <visit_goal_buyer>1</visit_goal_buyer>
        <referer_type>1</referer_type>
        <referer_name></referer_name>
        <referer_url>https://www.mydomain.com/path/userdata.php</referer_url>
        <referer_keyword></referer_keyword>
        <config_id>CÚ"ôê‚'</config_id>
        <config_os>WI7</config_os>
        <config_browser_name>FF</config_browser_name>
        <config_browser_version>4.0</config_browser_version>
        <config_resolution>1600x900</config_resolution>
        <config_pdf>1</config_pdf>
        <config_flash>1</config_flash>
        <config_java>1</config_java>
        <config_director>0</config_director>
        <config_quicktime>0</config_quicktime>
        <config_realplayer>0</config_realplayer>
        <config_windowsmedia>0</config_windowsmedia>
        <config_gears>0</config_gears>
        <config_silverlight>0</config_silverlight>
        <config_cookie>1</config_cookie>
        <location_ip>[3²Ê</location_ip>
        <location_browser_lang>de-de,en-us,de,en</location_browser_lang>
        <location_country>de</location_country>
        <location_continent>eur</location_continent>
        <location_provider>t-dialin.net</location_provider>
        <visitor_days_since_last>0</visitor_days_since_last>
        <visitor_days_since_order>0</visitor_days_since_order>
        <visitor_days_since_first>1</visitor_days_since_first>
    </piwik_log_visit>
    <piwik_log_visit>
        <idvisit>700280</idvisit>
        <idsite>15</idsite>
        <idvisitor>órٍó¹ </idvisitor>
        <visitor_localtime>12:44:24</visitor_localtime>
        <visitor_returning>1</visitor_returning>
        <visitor_count_visits>6</visitor_count_visits>
        <visit_first_action_time>2011-06-22 10:44:39</visit_first_action_time>
        <visit_last_action_time>2011-06-22 10:47:54</visit_last_action_time>
        <visit_exit_idaction_url>197185</visit_exit_idaction_url>
        <visit_exit_idaction_name>196806</visit_exit_idaction_name>
        <visit_entry_idaction_url>0</visit_entry_idaction_url>
        <visit_entry_idaction_name>0</visit_entry_idaction_name>
        <visit_total_actions>9</visit_total_actions>
        <visit_total_time>195</visit_total_time>
        <visit_goal_converted>0</visit_goal_converted>
        <visit_goal_buyer>2</visit_goal_buyer>
        <referer_type>1</referer_type>
        <referer_name></referer_name>
        <referer_url>http://www.mydomain.com/path/cat/abc/xyz.html</referer_url>
        <referer_keyword></referer_keyword>
        <config_id>CÚ"ôê‚'</config_id>
        <config_os>WI7</config_os>
        <config_browser_name>FF</config_browser_name>
        <config_browser_version>4.0</config_browser_version>
        <config_resolution>1600x900</config_resolution>
        <config_pdf>1</config_pdf>
        <config_flash>1</config_flash>
        <config_java>1</config_java>
        <config_director>0</config_director>
        <config_quicktime>0</config_quicktime>
        <config_realplayer>0</config_realplayer>
        <config_windowsmedia>0</config_windowsmedia>
        <config_gears>0</config_gears>
        <config_silverlight>0</config_silverlight>
        <config_cookie>1</config_cookie>
        <location_ip>[3²Ê</location_ip>
        <location_browser_lang>de-de,en-us,de,en</location_browser_lang>
        <location_country>de</location_country>
        <location_continent>eur</location_continent>
        <location_provider>t-dialin.net</location_provider>
        <visitor_days_since_last>0</visitor_days_since_last>
        <visitor_days_since_order>0</visitor_days_since_order>
        <visitor_days_since_first>1</visitor_days_since_first>
    </piwik_log_visit>
    <piwik_log_visit>
        <idvisit>700276</idvisit>
        <idsite>15</idsite>
        <idvisitor>órٍó¹ </idvisitor>
        <visitor_localtime>12:43:16</visitor_localtime>
        <visitor_returning>1</visitor_returning>
        <visitor_count_visits>6</visitor_count_visits>
        <visit_first_action_time>2011-06-22 10:43:32</visit_first_action_time>
        <visit_last_action_time>2011-06-22 10:44:39</visit_last_action_time>
        <visit_exit_idaction_url>196807</visit_exit_idaction_url>
        <visit_exit_idaction_name>196806</visit_exit_idaction_name>
        <visit_entry_idaction_url>0</visit_entry_idaction_url>
        <visit_entry_idaction_name>0</visit_entry_idaction_name>
        <visit_total_actions>6</visit_total_actions>
        <visit_total_time>67</visit_total_time>
        <visit_goal_converted>0</visit_goal_converted>
        <visit_goal_buyer>2</visit_goal_buyer>
        <referer_type>1</referer_type>
        <referer_name></referer_name>
        <referer_url>http://www.mydomain.com/path/product/sebb123/</referer_url>
        <referer_keyword></referer_keyword>
        <config_id>CÚ"ôê‚'</config_id>
        <config_os>WI7</config_os>
        <config_browser_name>FF</config_browser_name>
        <config_browser_version>4.0</config_browser_version>
        <config_resolution>1600x900</config_resolution>
        <config_pdf>1</config_pdf>
        <config_flash>1</config_flash>
        <config_java>1</config_java>
        <config_director>0</config_director>
        <config_quicktime>0</config_quicktime>
        <config_realplayer>0</config_realplayer>
        <config_windowsmedia>0</config_windowsmedia>
        <config_gears>0</config_gears>
        <config_silverlight>0</config_silverlight>
        <config_cookie>1</config_cookie>
        <location_ip>[3²Ê</location_ip>
        <location_browser_lang>de-de,en-us,de,en</location_browser_lang>
        <location_country>de</location_country>
        <location_continent>eur</location_continent>
        <location_provider>t-dialin.net</location_provider>
        <visitor_days_since_last>0</visitor_days_since_last>
        <visitor_days_since_order>0</visitor_days_since_order>
        <visitor_days_since_first>1</visitor_days_since_first>
    </piwik_log_visit>
    <piwik_log_visit>
        <idvisit>700270</idvisit>
        <idsite>15</idsite>
        <idvisitor>órٍó¹ </idvisitor>
        <visitor_localtime>12:41:19</visitor_localtime>
        <visitor_returning>1</visitor_returning>
        <visitor_count_visits>6</visitor_count_visits>
        <visit_first_action_time>2011-06-22 10:41:35</visit_first_action_time>
        <visit_last_action_time>2011-06-22 10:43:32</visit_last_action_time>
        <visit_exit_idaction_url>196807</visit_exit_idaction_url>
        <visit_exit_idaction_name>196806</visit_exit_idaction_name>
        <visit_entry_idaction_url>0</visit_entry_idaction_url>
        <visit_entry_idaction_name>0</visit_entry_idaction_name>
        <visit_total_actions>16</visit_total_actions>
        <visit_total_time>117</visit_total_time>
        <visit_goal_converted>0</visit_goal_converted>
        <visit_goal_buyer>2</visit_goal_buyer>
        <referer_type>1</referer_type>
        <referer_name></referer_name>
        <referer_url>http://www.mydomain.com/path/product/products-name/</referer_url>
        <referer_keyword></referer_keyword>
        <config_id>CÚ"ôê‚'</config_id>
        <config_os>WI7</config_os>
        <config_browser_name>FF</config_browser_name>
        <config_browser_version>4.0</config_browser_version>
        <config_resolution>1600x900</config_resolution>
        <config_pdf>1</config_pdf>
        <config_flash>1</config_flash>
        <config_java>1</config_java>
        <config_director>0</config_director>
        <config_quicktime>0</config_quicktime>
        <config_realplayer>0</config_realplayer>
        <config_windowsmedia>0</config_windowsmedia>
        <config_gears>0</config_gears>
        <config_silverlight>0</config_silverlight>
        <config_cookie>1</config_cookie>
        <location_ip>[3²Ê</location_ip>
        <location_browser_lang>de-de,en-us,de,en</location_browser_lang>
        <location_country>de</location_country>
        <location_continent>eur</location_continent>
        <location_provider>t-dialin.net</location_provider>
        <visitor_days_since_last>0</visitor_days_since_last>
        <visitor_days_since_order>0</visitor_days_since_order>
        <visitor_days_since_first>1</visitor_days_since_first>
    </piwik_log_visit>
</analytics_mediatac_net>

Im pretty sure this has something to do with the tracker-updates in shopping cart every time the user visits it …

Regards
wit

link to fullsize-screenshot:
http://intra.ath.cx/1-visitor-as-4.jpg

Hi,

I have the same problem, every time a visitor visits the cart.
I have made the one-click update form Piwik 1.4 to 1.5.
IP of my visitor doesn’t changed, because I’m testing Piwik 1.5 on localhost.

Any ideas?

Greets

problem also occurs on a fresh Piwik 1.5 installation.

Here is the tracker code:

var pkBaseURL = ((“https:” == document.location.protocol) ? “https://localhost/webtracker.essenzia-shop.de/” : “http://localhost/webtracker.essenzia-shop.de/” );
document.write(unescape("%3Cscript src=’" + pkBaseURL + “piwik.js’ type=‘text/javascript’%3E%3C/script%3E” ) );

try {
var piwikTracker = Piwik.getTracker(pkBaseURL + “piwik.php”, 1);
piwikTracker.addEcommerceItem(“1”,“Bio-Schwarzkümmelöl (100ml)”,“Essenzia-Öle”,14.95,1);
piwikTracker.trackEcommerceCartUpdate(14.95);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}

Realtime Widget looks like this, when a visitor visits the cart/ adds several items to chart.
[attachment 250 cart.PNG]

I could confirm this problem too. A lot of visitors (all?) with items in cart are split into two visits. This pushes the total of my abandoned carts to very high (and probably false) values.

Regards from Germany!

Hi,

have a look at this ticket: Ecommerce tracking - Added Items are always shown as abandoned cart · Issue #2528 · matomo-org/matomo · GitHub

Please post your problem and experience in this ticket.

Regards from Germany too!

Hi Machoyer,

I’m not sure that the ticket and this thread matches. The ticket discusses the problem that every unordered cart is tracked as abandoned whereas this thread complains about generating multiple visits for a single user when he/she is adding / removing items from the cart.

But maybe it is best to open another ticket for this problem, too!

Best

To all users experiencing the problem “A lot of visitors (all?) with items in cart are split into two visits” -> please PM me your Piwik URL + login + password + bug description so I can see the problem by myself. Of course we would like to fix such issue as soon as possible :slight_smile:

you’ve got a PM…

Regards!

I had the same exact problem, each cart update would generate a new visitor. However, I finally realized that addEcommerceItem simply pushes a value to the item array and a request is not sent until doTrackEcommerceCartUpdate is called. My code was calling doTrackGoal before doTrackEcommerceCartUpdate. So what you’d want to do is call doTrackEcommerceCartUpdate immediately after your addEcommerceItem loop to send the request and clear out the ecommerce items array,

What I mentioned above was for using the php sdk,. Taking a look at the javascript, however, I’m not sure if ecommerceItems is being reset after the first request like in the php sdk. This may cause problems when sending multiple requests.

Hi Gator,

I can’t acknowledge that. I do call trackEcommerceCartUpdate (not “doTrackEcommerceCartUpdate”) immediately after addEcommerceItem and get 2 visits…

[attachment 272 screenshot.jpg]

Best,
JMC

jmcblog, could you please email me at matt att piwik.org so we can discuss the problem and find the cause? thanks!

Hello guys

Thanks for your patience for this problem. I was investigating and found a potential bug in Tracker!

Can you please patch the following in your Piwik, and then test if the double visit problem is still there?


There is a trivial fix to the file core/Tracker/Visit.php
http://dev.piwik.org/trac/changeset/5167#file0

Can you please apply and then, check to generate double visit and see if the bug is still there?

PLease confirm guys, many thanks

I’ve has tested those lines,but i got still the same problem. Every time a cart it’s viewed a new visit is created, also with the patched data.

wshqq, can you please email me at matt@piwik and let me know your Piwik URL, login & password, and also how to replicate the bug on your website URL
I really want to fix this issue before the next release, thanks!

Hello all users experiencing this bug

I think maybe I found the bug that some of you are experiencing. the patch is very simple, please apply it: http://dev.piwik.org/trac/changeset/5171

and let me know here if you still experience issues after this patch. If you do, please email me at matt att piwik.org thanks!