If this is your first visit, check our documentation. To post, register or login.
Forums / All Other Contributions/Addons / User tracking mod

User tracking mod

Started by pinghead on 10 May 2006, 12:06 PM · Views: 184,890

Results 141 to 160 of 861
27 Nov 2006, 9:48 PM
#141
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

User tracking mod

Hi all:

I have uploaded a new version of the user tracking tool to the Zencart downloads area. Until it is released I updated the user tracking archive posted previously in (post 131) above to include the full fileset with all recent changes.

Taken from the readme, here are a list of the changes:

Modified the user_tracking.sql by extending the size of the last_page_url field from 64 characters to 128 characters as this was previously too short and would often truncate URL link data.

Truncated the session_id field from 128 characters to 32 characters as this was wasted space.

Changed the script itself into a form and added a popup date selection menu so you can select a specific date to begin the listing.

Fixed the functions to work with sql 5.x and for longer last_page_url field writes.

Added a missing country flag or two.

Included the latest GeoIP.dat file.

Updated language defines for the popup additions.

Installation is simple, just replace all current files with those in the archive and execute the sql provided in the readme.

Please let me know if you find any issues?

Jeff

28 Nov 2006, 11:55 AM
#142
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: User tracking mod

JeffD:

It is possible this behaved differently in 1.2x Zencart as there were changes made to the logoff and the session handling since that version but at least for now I don't see an easy way to change this behavior.
Yes I don't see this same behavior in a 1.27 shop yet to be upgraded.

Firefox2 provides an ability to manually clear "authenticated sessions" from private data. When I do this and then log back in to the customer account, User Tracking running on the 1.3x shop, indeed shows a new session was created.

Pity the changes from 1.2x to 1.3x decreased the usefulness of the User Tracking mod.

Thanks for the info.

Woody

28 Nov 2006, 12:55 PM
#143
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: User tracking mod

JeffD:

Modified the user_tracking.sql by extending the size of the last_page_url field from 64 characters to 128 characters as this was previously too short and would often truncate URL link data.

Hi Jeff-

My assumption is the sql below is for those updating from the previous version of User Tracking (08/31/2006 - Version: 20060805 by PingHead)?

Below is the commands necessary for the sql patch tool to alter the table to the new format described in the user_tracking.sql and described above:

ALTER TABLE user_tracking CHANGE session_id session_id VARCHAR(32);
ALTER TABLE user_tracking CHANGE last_page_url last_page_url VARCHAR(128);

Thanks for the update,
Woody

28 Nov 2006, 1:12 PM
#144
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: User tracking mod

Yes, if you want to keep current table data intact just execute those two commands or if you don't care and want to drop the table and create a fresh one execute the user_tracking.sql contents.

Jeff

28 Nov 2006, 2:41 PM
#145
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: User tracking mod

Regarding Jeff's new update...

Using previous version I implemented the following solution provided by Andrew (a_berezin) in post #129 of this thread, to make User Tracking work correctly with Admin Profiles installed (solves issue with User Tracking Config incorrectly displaying twice in the admin menus, so instead of also showng up in the Tools menu, it now only displays on the Configuration menu).

21st November 2006, 01:51 PM

  1. Run this sql-patch:

UPDATE configuration_group SET visible = '1' WHERE configuration_group_id =999 LIMIT 1 ;

  1. Remove user_tracking_config.php from user_tracking_tools_dhtml.php box (for admin_profile):

$options = array( array('box' => BOX_TOOLS_USER_TRACKING, 'page' => FILENAME_USER_TRACKING) );

  1. Remove user_tracking_config.php file from admin directory.
    Following step 3 above should I not upload /admin/user_tracking_config.php for the new version?

Thanks,
Woody

28 Nov 2006, 3:13 PM
#146
irischant avatar

irischant

New Zenner

Join Date:
Nov 2004
Location:
Pittsburgh, PA
Posts:
23
Plugin Contributions:
0

Re: User tracking mod

I've just installed this for the first time & am getting the following error when I try to access User Tracking Configuration in admin:

Fatal error: Cannot use object of type queryFactoryResult as array in /home/blubrix/public_html/admin/user_tracking_config.php on line 107

The main User Tracking page in admin seems to be working just fine, it's just the configuration that's not pulling through here. I'm using 1.3.6...no previous installs of this mod & no Admin Profiles installs either.

28 Nov 2006, 3:21 PM
#147
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: User tracking mod

Woody:

Yes, if you can somehow force the session id to change once you logoff as the customer (by any means available) then the user tracking data should display as "Guest" for the balance of the browser session.

The problem is simply when you logoff as a customer the session id remains the same (even though the session has been destroyed) so the session tracking continues to record (as Guest) but under the existing (same) session id and since the session id was previously associated with the customer account, continues to display this way. I am not aware of any PHP call that could be made at this point to aquire a different session id.

Jeff

28 Nov 2006, 3:47 PM
#148
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: User tracking mod

Comparing the contents of /admin/images/flags in the new version of User Tracking with he previous version.

I observe two new flag image files
ps.gif
sv.gif

The flags directory for the new version contains 170 flag images.

I observe the following files are no longer provided:
kw.gif (Kuwait)
.gif
0.gif

Any thoughts why the flag for Kuwait was deleted from /admin/images/flags and which countries PS & SV represent?

And what did 0.gif and .gif. I know they both were the same image but could not identify the flag.

I observe the 'countries' table for Zen Cart 1.36 contains 240 records. Any ideas on how to round up additional 70 missing flag images?

In the 'countries' table I observe no reference to any country with PS or SV in the countries_iso_code_2 field.

Anyone know of a quick method to confirm the number of countries listed in the GeoIP.dat database?

Anyone know if the ISO is the authoritative source for the actual number of countries "in existence" at a particular time.

Woody

28 Nov 2006, 3:48 PM
#149
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: User tracking mod

irischant:

I'm sorry there were errors and ommisions in the sql of the archive.

Please execute the following in the sql patch too and it should get you fixed up:

DROP TABLE IF EXISTS user_tracking;
CREATE TABLE user_tracking (
  `customer_id` int(11) default NULL,
  `click_id` int(11) default NULL,
  `full_name` varchar(64) NOT NULL default '',
  `session_id` varchar(32) NOT NULL default '',
  `ip_address` varchar(15) NOT NULL default '',
  `time_entry` varchar(14) NOT NULL default '',
  `time_last_click` varchar(14) NOT NULL default '',
  `last_page_url` varchar(128) NOT NULL default '',
  `referer_url` varchar(254) NOT NULL default '',
  `page_desc` varchar(64) NOT NULL default ''
) TYPE=MyISAM;




DELETE FROM configuration where configuration_group_id = '999';
INSERT INTO `configuration_group` (`configuration_group_id`, `configuration_group_title`, `configuration_group_description`, `sort_order`, `visible`) VALUES (999, 'User Tracking Config', 'User Tracking', 31, 1);
INSERT INTO configuration VALUES ('', 'User Tracking (ADMIN)', 'ADMIN_CONFIG_USER_TRACKING', 'true', 'Check the ADMINs behaviour ? (each click will be recorded)', 999, 2, '2003-03-03 11:19:26', '2003-02-09 21:20:07', NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'User Tracking (exclude this IP-Address)', 'CONFIG_USER_TRACKING_EXCLUDED', 'your IP', 'Do NOT record this IP Address<br>(like webmaster/owners/Beta-testers)', 999, 10, '2003-03-04 23:08:38', '2003-02-09 21:20:07', NULL, NULL);
INSERT INTO configuration VALUES ('', 'User Tracking (Session Limit)', 'CONFIG_USER_TRACKING_SESSION_LIMIT', '50', 'Displaying the latest # sessions of this 24 hour period.<br>(SET to 999999 for unlimited per 24 hour period)<br>NOTE:<BR>Watch you space !', 999, 15, '2003-03-03 11:19:13', '2003-02-09 21:20:07', NULL, NULL);
INSERT INTO configuration VALUES ('', 'User Tracking (your favorite WHOIS URL)', 'USER_TRACKING_WHOIS_URL', 'http://www.dnsstuff.com/tools/whois.ch?ip=', 'Put here you favorite WHOIS tracking site<br>(the IP will follow automaticly after this url)', 999, 50, '2003-03-03 11:19:13', '2003-03-11 11:40:01', NULL, NULL);
INSERT INTO configuration VALUES ('', 'User Tracking Visitors', 'ZEN_CONFIG_USER_TRACKING', 'true', 'Check the Customers/Guests behaviour ? (each click will be recorded)', 999, 1, '2003-03-03 11:19:26', '2003-02-09 21:20:07', NULL, 'zen_cfg_select_option(array(''true'', ''false''),');

I will correct the archive sql and re-upload in a few minutes.

Jeff

28 Nov 2006, 4:04 PM
#150
irischant avatar

irischant

New Zenner

Join Date:
Nov 2004
Location:
Pittsburgh, PA
Posts:
23
Plugin Contributions:
0

Re: User tracking mod

Hi Jeff

I just applied that patch, cleared my browser cache & am still getting the same error.

28 Nov 2006, 4:06 PM
#151
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: User tracking mod

Woody:

If you have additional flags that you've added (like Kuwait) send them to me and I'll include them in the archive. The ones I've added were simply a result of finding missing image indicators in the output and figuring out what country it was, locating a flag for said country and scaling it to size. The ps.gif is Palestine Occupied Territory, it was the last I added so I remember it. Don't remember what sv.gif is now.

I don't believe the 0.gif and .gif are needed any more as I fixed the code to display a US flag if GEO_IP doesn't return a valid reference...

I don't have answers for the balance of your questions, sorry!

Jeff

28 Nov 2006, 4:13 PM
#152
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: User tracking mod

Woody:

Open the file admin/includes/geoip.inc to see the possible GEO_IP country return codes. Hope this helps!

Jeff

28 Nov 2006, 4:13 PM
#153
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: User tracking mod

JeffD:

The problem is simply when you logoff as a customer the session id remains the same (even though the session has been destroyed) so the session tracking continues to record (as Guest) but under the existing (same) session id and since the session id was previously associated with the customer account, continues to display this way.

Thanks for the info Jeff,

Is this not by Zen Cart design? So that the guest shopping cart contents remains known when the guest creates/logs into an account (when the cart for the guest and newly logged in user are merged).

And also the same if logged in user logs out, and then later logs back in?

So is the session_id IP based or browser based? That is if I moved to another PC using the same IP, or fired up a different browser on the same PC, would we see the same effect? I hope I am being clear. Time for some research on my part. ;-)

I suspect the ZC Dev team has been dealing with this issue since day one.

Woody

28 Nov 2006, 4:30 PM
#154
irischant avatar

irischant

New Zenner

Join Date:
Nov 2004
Location:
Pittsburgh, PA
Posts:
23
Plugin Contributions:
0

Re: User tracking mod

Jeff...I think I've tracked it down here

in user_tracking_config.php starting with line 106 I've changed the following from:

    if (((!$HTTP_GET_VARS['cID']) || (@$HTTP_GET_VARS['cID'] == $configuration->fields['configuration_id'])) && (!$cInfo) && (substr($HTTP_GET_VARS['action'], 0, 3) != 'new')) {
      $cfg_extra = $db->Execute("select configuration_key, configuration_description, date_added, last_modified, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_id = '" . $configuration['configuration_id'] . "'");

      $cInfo_array = array_merge($configuration, $cfg_extra);
      $cInfo = new objectInfo($cInfo_array);
    }

to:

    if (((!$HTTP_GET_VARS['cID']) || (@$HTTP_GET_VARS['cID'] == $configuration->fields['configuration_id'])) && (!$cInfo) && (substr($HTTP_GET_VARS['action'], 0, 3) != 'new')) {
      $cfg_extra = $db->Execute("select configuration_key, configuration_description, date_added, last_modified, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_id = '" . (int)$configuration->fields['configuration_id'] . "'");

      $cInfo_array = array_merge($configuration->fields, $cfg_extra->fields);
      $cInfo = new objectInfo($cInfo_array);
    }

Seems to work peachy now ;c)

28 Nov 2006, 4:47 PM
#155
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: User tracking mod

irischant:

Thanks for updating the code and posting your fix. You may have some more restrictive PHP settings regarding arrays than some as I have not had an issue here but your fixes make sense so I will include them in the next update. Again thank you!

Woody:

No, not by Zencart design but rather by PHP design since the session id is actually generated from within the PHP engine not within Zencart code.

The session is used in Zencart to track the user so yes in that case when he creates an account, has his cart merged etc., the session id is used as the reference.

The session id is neither IP based nor browser based. As I said it is generated by the PHP server to track a specific HTTP connection. If the same user logs out and back in without closing the browser he will likely get the same session id, unless the session has expired in which case he may get a different session id.

Different machines will get different sessions always but multiple connections on the same machine with the same browser will share the same session. Try opening several Firefox browser instances connecting to your store and several through I.E. and you will likely see two different sessions between browsers (unless you log in as the same customer in which case your sessions will be merged). If you play around like this while watching your user tracking session id's I think it will become clearer how it all works.

Hope this helps!
Jeff

28 Nov 2006, 4:48 PM
#156
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: User tracking mod

JeffD:

Open the file admin/includes/geoip.inc to see the possible GEO_IP country return codes. Hope this helps!
Good eye. From the include file I calculated the latest version of GeoIP.dat supports 243 countries.

So the countries' table Zen Cart 1.36' is missing 3 countries. Or maybe not. I see GeoIP includes EU which is not a country per se.

I found an ISO list at:
http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html

ISO site currently shows 244 official short names and code elements.

I see a good source of medium and larger sized flags at https://www.cia.gov/cia/publications/factbook/docs/flagsoftheworld.html

What is the generally acceptable source for those tiny flag gif files? I think the same are used by AWStats.

So my tally is:
Zen Cart = 240
ISO = 244
GeoIP = 243
CIA = 237
UT flags = 170

I never know when a potential customer from the ÅLAND ISLANDS may visit my shop and then submit a huge order. Need to be ready for that day ;-)

-Woody

28 Nov 2006, 4:55 PM
#157
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: User tracking mod

Woody:

AFAIK they are simply 18px wide by 12px high gif images.

BTW, I think you just volunteered to be the official user_tracking country flag provider! When you have them all ready... send them to me and I'll update the archive. :laugh:

Thanks!
Jeff

28 Nov 2006, 5:49 PM
#159
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: User tracking mod

JeffD:

Different machines will get different sessions always but multiple connections on the same machine with the same browser will share the same session. Try opening several Firefox browser instances connecting to your store and several through I.E. and you will likely see two different sessions between browsers (unless you log in as the same customer in which case your sessions will be merged). If you play around like this while watching your user tracking session id's I think it will become clearer how it all works.

Hope this helps!
Yes that was very helpful. When I stated "browser based" what you descibe above is what I was referring to. Different browsers on the same machine will not share the same session. But if multiple connections made from different windows/tabs in the same browser they would share the same session. Because the connections from each window refers to the same browser client side authenticated sessions table.

So if this is an inherent structural feature in the PHP-Apache platform, wondering how carts developed on other development platforms/languages deal with this issue? Or do they?

Time for me to take a PHP/LAMP programing class.

Woody

28 Nov 2006, 8:34 PM
#160
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: User tracking mod

Woody:

Every language that supports HTTP protocol has the concept of a session object and accessors to add and remove session parameters, check for session expiration, etc. This would include JAVA, C++, PERL, and the list goes on and on. They all pretty much do the same thing as PHP so if you learn one you learn them all. :yes:

Jeff