fortwilliam
Programmer
Hi, I am trying to record what people are searching for before they come to the html pages on my site.
The following is the code I have tried on the html pages and then the main parts of the perl script. The perl script just takes the referrer value and if it is from google|bing|yahoo it then removes all but the search term and prints to a text file. I have also just printed the referred value to screen to see what is going on.
Trouble is all I get as the reffering page is the page the code is on. So, if I have the code on mysite.com/this-page.html, that is what I get as the reffering page in the javascript, image and iframe.
Thanks
<script language="JavaScript" type="text/javascript" src="\\\perl///script.pl"></script>
<img src="\\\perl///script.pl" border=0 height=0 width=0>
<iframe src ="\\\perl///script.pl"width="1" height="1">
\\\\\ part of perl script:-
&parse_form;
$ref=$ENV{'HTTP_REFERER'};
print"$ref";#added so I can see what is being reffered:: remove
if ($ref =~ /\.google\.|\.bing\.|\.yahoo\./i){
$ref =~ s/.*[\&|\?][q|p]=([\w*\+?(%20)? ?]*)/$1/;
$ref =~ s/\+|%20/ /g;
open (LOG, ">>\\my\\path\\seng.txt");
flock(LOG, 2);
print LOG "$ref\n";
flock(LOG, 8);
close (LOG);
}
The following is the code I have tried on the html pages and then the main parts of the perl script. The perl script just takes the referrer value and if it is from google|bing|yahoo it then removes all but the search term and prints to a text file. I have also just printed the referred value to screen to see what is going on.
Trouble is all I get as the reffering page is the page the code is on. So, if I have the code on mysite.com/this-page.html, that is what I get as the reffering page in the javascript, image and iframe.
Thanks
<script language="JavaScript" type="text/javascript" src="\\\perl///script.pl"></script>
<img src="\\\perl///script.pl" border=0 height=0 width=0>
<iframe src ="\\\perl///script.pl"width="1" height="1">
\\\\\ part of perl script:-
&parse_form;
$ref=$ENV{'HTTP_REFERER'};
print"$ref";#added so I can see what is being reffered:: remove
if ($ref =~ /\.google\.|\.bing\.|\.yahoo\./i){
$ref =~ s/.*[\&|\?][q|p]=([\w*\+?(%20)? ?]*)/$1/;
$ref =~ s/\+|%20/ /g;
open (LOG, ">>\\my\\path\\seng.txt");
flock(LOG, 2);
print LOG "$ref\n";
flock(LOG, 8);
close (LOG);
}