Jump to content
Sign in to follow this  
Sandbag

[Contribution] Leapfrog - Dynamic Visitor Tracking

Recommended Posts

I've got the same issue with bots being displayed as guests. It seems that $spider_flag is always false when accessed in /catalog/includes/functions/leapfrog.php. I tried to add another variable to application_top and set it to true or false depending on the value of $spider_flag. Then I used this in leapfrog but it still doesn't work. So my guess is that for some reason $spider_flag cannot be used to check if it's a bot or not. Strangely enough the original purpose of assigning a session id or not is working fine. Maybe $spider_flag is reset later?

 

abra


The First Law of E-Commerce: If the user can't find the product, the user can't buy the product.

 

Feedback and suggestions on my shop welcome.

 

Note: My advice is based on my own experience or on something I read in these forums. No guarantee it'll work for you! Make sure that you always BACKUP the database and the files you are going to change so that you can rollback to a working version if things go wrong.

Share this post


Link to post
Share on other sites
I've got the same issue with bots being displayed as guests. It seems that $spider_flag is always false when accessed in /catalog/includes/functions/leapfrog.php. I tried to add another variable to application_top and set it to true or false depending on the value of $spider_flag. Then I used this in leapfrog but it still doesn't work. So my guess is that for some reason $spider_flag cannot be used to check if it's a bot or not. Strangely enough the original purpose of assigning a session id or not is working fine. Maybe $spider_flag is reset later?

 

abra

 

Yeah it could be reset somewhere else. I think in the next version, I will do the spider identification when extracting the db info, and not when it goes in. This should help eliminate problems like this.

Share this post


Link to post
Share on other sites
Yeah it could be reset somewhere else. I think in the next version, I will do the spider identification when extracting the db info, and not when it goes in. This should help eliminate problems like this.

 

I don't think it's a good idea since in many cases (like mine) robots do thousands of hits per hour...

Why not using the session_id instead ? seems to work fine

 

Franco


Outside links in signatures are not allowed!

Share this post


Link to post
Share on other sites

For the situation when you want to show all guests and bots, here is a fix to the problem that even bots were shown as guests.

 

In /catalog/includes/functions/leapfrog.php (lines 51 to 84) find:

    } else {

		// No they don't
     $wo_customer_id = '';

		// Is the visitor a bot? If so, show it's name.
		// The $spider_flag variable is set in application_top.php.
		if ($spider_flag == true) {

			// It's a bot. Extract the bots name
			$wo_full_name = '[bot] ';

			$user_agent = getenv('HTTP_USER_AGENT');
			if (tep_not_null($user_agent)) {

				// Bot string is of form - "Mozilla/5.0 (compatible; Yahoo! Slurp; [url="http://help.yahoo.com/help/us/ysearch/slurp%29%22"]http://help.yahoo.com/help/us/ysearch/slurp)"[/url]

				$needle = '(compatible;';
				$bot_name_start_pos = strpos($user_agent, $needle);
				$bot_name = substr($user_agent, $bot_name_start_pos+strlen($needle));
				$bot_name_end_pos = strpos($bot_name, ';');
				$bot_name = substr($bot_name, 0, $bot_name_end_pos);
				$wo_full_name .= tep_db_input(tep_db_prepare_input($bot_name));

			} else {
				$wo_full_name .= 'Unknown spider';
			}

		} else {
		  // This is just a regular guest.
    	 	$wo_full_name = 'Guest';
		}

   }

 

and replace with:

    } else {

		// No they don't
     $wo_customer_id = '';

		// Is the visitor a bot? If so, show it's name.
		// Check user agent string against spiders.txt.
			$user_agent = strtolower(getenv('HTTP_USER_AGENT'));
			$spider = false;
			if (tep_not_null($user_agent)) {
				$spiders = file(DIR_WS_INCLUDES . 'spiders.txt');
				for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
					if (tep_not_null($spiders[$i])) {
						if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
							$spider = true;
							break;
						}
					}
				}
			}

			if ($spider){
				// It's a bot. Extract the bots name
				$wo_full_name = '[bot] ';

				// Bot string is of form - "Mozilla/5.0 (compatible; Yahoo! Slurp; [url="http://help.yahoo.com/help/us/ysearch/slurp%29%22"]http://help.yahoo.com/help/us/ysearch/slurp)"[/url]	
				$needle = '(compatible;';
				$bot_name_start_pos = strpos($user_agent, $needle);
				$bot_name = substr($user_agent, $bot_name_start_pos+strlen($needle));
				$bot_name_end_pos = strpos($bot_name, ';');
				$bot_name = substr($bot_name, 0, $bot_name_end_pos);
				if ($bot_name == '') {
					// Bot string is of form - "msnbot/1.0 ( [url="http://search.msn.com/msnbot.htm%29%22"]http://search.msn.com/msnbot.htm)"[/url]
					$bot_name_end_pos = strpos($user_agent, '(');
					$bot_name = substr($user_agent, 0, $bot_name_end_pos);
				} else {
					// Bot string is of different form
					if ($bot_name == ''){
					$bot_name = $user_agent;
					}
				}
				$wo_full_name .= tep_db_input(tep_db_prepare_input($bot_name));
			} else {
				// This is just a regular guest.
				$wo_full_name = 'Guest';
			}

			$wo_full_name .= ' - #'; // just a cosmetic change	
   }

 

abra

Edited by abra123cadabra

The First Law of E-Commerce: If the user can't find the product, the user can't buy the product.

 

Feedback and suggestions on my shop welcome.

 

Note: My advice is based on my own experience or on something I read in these forums. No guarantee it'll work for you! Make sure that you always BACKUP the database and the files you are going to change so that you can rollback to a working version if things go wrong.

Share this post


Link to post
Share on other sites

Ok, this was the long workaround...

 

I finally figured out why it didn't recognise the value set for $spider_flag...

 

In /catalog/includes/functions/leapfrog.php (line 34) add $spider_flag to the list of globals so that it looks like this:

  function lf_update_tracking() 
 {
   global $customer_id, $languages_id, $HTTP_GET_VARS, $HTTP_SERVER_VARS, $spider_flag;

 

Like this you don't need to find and replace any other text as mentioned in my previous post. And the setting to not display bots at all should work now too. They will not be added to the database as they are filtered out first.

 

abra


The First Law of E-Commerce: If the user can't find the product, the user can't buy the product.

 

Feedback and suggestions on my shop welcome.

 

Note: My advice is based on my own experience or on something I read in these forums. No guarantee it'll work for you! Make sure that you always BACKUP the database and the files you are going to change so that you can rollback to a working version if things go wrong.

Share this post


Link to post
Share on other sites

Hi,

 

why I keep getting disconnected from the DB ?

 

this is the msg I get:

 

Unable to connect to the Leapfrog data feed.

 

Please read the following suggestions:

 

1. Do you have an admin login contribution installed? If so you must edit it to allow Leapfrog to access '/admin/leapfrog_feed.php'.

 

2. Are you using IE and SSL? There is a known issue with this setup. Please see INSTALL.txt for details. Alternatively switch to Firefox.

 

3. Visit the support thread on the official osCommerce forum. There might be an answer there.


Outside links in signatures are not allowed!

Share this post


Link to post
Share on other sites
How often is this error message appearing, and what is the error code show? LDF004? Are you using SSL? What browser are you running?

 

Hi,

 

yes, the code is LDF004. I'm currently using IE, I'll have a try with FF as well.

The error happens quite often


Outside links in signatures are not allowed!

Share this post


Link to post
Share on other sites

I also noticed that registered users are not recognized , at least not me browsing in another window


Outside links in signatures are not allowed!

Share this post


Link to post
Share on other sites

Leapfrog got stuck with FF as well :-( after about 5 mins


Outside links in signatures are not allowed!

Share this post


Link to post
Share on other sites
Leapfrog got stuck with FF as well :-( after about 5 mins

 

In the admin menu you will see the Leapfrog menu. You can access Leapfrog by clicking on the HEADER of this menu.

 

When the menu EXPANDS, you will see another Leapfrog link below. This one links to a NON SSL version of Leapfrog. Please can you try using this link to run Leapfrog and see if you still get the error.

 

You will know you are on the correct page because the URL in the address bar will be http:// not https://.

 

Thanks.

Share this post


Link to post
Share on other sites
In the admin menu you will see the Leapfrog menu. You can access Leapfrog by clicking on the HEADER of this menu.

 

When the menu EXPANDS, you will see another Leapfrog link below. This one links to a NON SSL version of Leapfrog. Please can you try using this link to run Leapfrog and see if you still get the error.

 

You will know you are on the correct page because the URL in the address bar will be http:// not https://.

 

Thanks.

 

Ed,

I'm not under SSL on my admin


Outside links in signatures are not allowed!

Share this post


Link to post
Share on other sites

Nothing is showing up? I have changed to this "if (true)}" in the funtions leapfrog.php? All that I can see the the setting button and at the bottom browser it says it is transfer data.

Share this post


Link to post
Share on other sites

also when I view source see this "/srcview/index.html 404". I have look for this file and no luck. I am missing somthing? I am using firefox also?

Edited by pbpools

Share this post


Link to post
Share on other sites

When I view the source from leapfrog_feed.php?action=newclicks&lastclick=1 I only see this <?xml version="1.0" encoding="utf-8"?>

<clicks>

</clicks>

Share this post


Link to post
Share on other sites
When I view the source from leapfrog_feed.php?action=newclicks&lastclick=1 I only see this <?xml version="1.0" encoding="utf-8"?>

<clicks>

</clicks>

 

This means that tracking data is not being recorded in the database. Please look in the 'leapfrog' table in your database and check that rows are present.

Share this post


Link to post
Share on other sites
This means that tracking data is not being recorded in the database. Please look in the 'leapfrog' table in your database and check that rows are present.

This is what is in database: I do not see rows per say?

customer_id int(11) Yes NULL Browse distinct values Change Drop Primary Unique Index Fulltext

customer_name varchar(64) latin1_swedish_ci No Browse distinct values Change Drop Primary Unique Index Fulltext

customer_realname varchar(128) latin1_swedish_ci No Browse distinct values Change Drop Primary Unique Index Fulltext

session_id varchar(128) latin1_swedish_ci No Browse distinct values Change Drop Primary Unique Index Fulltext

ip_address varchar(15) latin1_swedish_ci No Browse distinct values Change Drop Primary Unique Index Fulltext

click_time varchar(14) latin1_swedish_ci No Browse distinct values Change Drop Primary Unique Index Fulltext

page_url varchar(255) latin1_swedish_ci No Browse distinct values Change Drop Primary Unique Index Fulltext

page_title varchar(64) latin1_swedish_ci No Browse distinct values Change Drop Primary Unique Index Fulltext

referer_url varchar(255) latin1_swedish_ci Yes NULL Browse distinct values Change Drop Primary Unique Index Fulltext

thumb_url

Share this post


Link to post
Share on other sites
No rows means that there is a problem inserting data. Please confirm that you have added the lf_update_tracking() code to footer.php.

here it is: Is it in the right place?

echo FOOTER_TEXT_BODY

?>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

<?php

require(DIR_WS_FUNCTIONS . 'leapfrog.php');

lf_update_tracking();

?>

Share this post


Link to post
Share on other sites
here it is: Is it in the right place?

echo FOOTER_TEXT_BODY

?>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

<?php

require(DIR_WS_FUNCTIONS . 'leapfrog.php');

lf_update_tracking();

?>

 

Also I am seeing this:

Alternate HTML content should be placed here. This content requires the Adobe Flash Player. Get Flash

 

I have the correct version of flash also?

Share this post


Link to post
Share on other sites

Well it working but after a few minutes I get this Code: LDF004. I am using firefox, and have change the install text? I can manually purge the database and it will work again.

Share this post


Link to post
Share on other sites
No rows means that there is a problem inserting data. Please confirm that you have added the lf_update_tracking() code to footer.php.

 

Yes it is there. still only works for a little bit.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×