This isn't exactly a perl question, is it?
Well, I guess it could be if you use mod_perl and set up some handler to replace some variable in your .html or .shtml with the document's http_referer. But nevermind ...
What you are clearly looking for is the SSI howto (http://httpd.apache.org/docs/howto/ssi.html) and the mod_include docs (http://httpd.apache.org/docs/mod/mod_include.html). The include variable will be something like ${HTTP_REFERER}
Oh, and I'm assuming that you're using Apache or perhaps some close relative thereof.
Not that I disagree with ichimunki in any way. Remember, some people turn off images and won't ever be counted by your script.
| [reply] |
Why wouldn't you just look at your server logs to figure out who came from where? Barring that, you probably don't want to put a reference to a script into an <img> tag. You probably want to capture the environment variable in your main script for that page. That's the only reliable time the browser is going to set referrer to a URL from somewhere else. Of course, I see that you want to track this for a static HTML file, which brings you back to server logs. I've never heard a compelling reason to use SSI over simply writing a Perl script to replace index.html with index.pl. | [reply] [d/l] |
Server logs ... thats true. I didnt think of that. Must have slipped my mind. But as far as not calling a script through an img tag, I'm only doing that because when I originally had the script setup, doing things other than http_referer tracking, the server didnt have ssi setup. And it worked. Plain and simple. I forgot about people who shut off images... ugh.
Replacing index.html with index.pl, is a solution. But only for that page. What if I would like to track every page within the site? But replacing index.html with index.pl, would definitally help in getting a 'true' http_referer value... altho, I am aware it can be faked, false, or just non-existant.
Maybe I'll just replace index.html with index.pl and reference everything thats a link within the site to a pl script ... naaa .. thats not a good solution.
Server logs it be. :) Thanks for the ideas/pointer in the right direction.
_14k4 - webmaster@860.org (www.860.org www.poorheart.com)
| [reply] |
Javascript will do exactly what you want. The only caveats
are that it only measures ppl with js enabled, and browser
bugs cause a decent # of false referrers (meaning the
'referrer' may actually be the site they were at before
they typed in your url, etc).
<SCRIPT LANGUAGE="JavaScript">
<!--//
var lt = unescape("%3c");
var gt = unescape("%3e");
var qt = unescape("%22");
var sq = unescape("%27");
document.write(lt + "IMG SRC=" + qt + "http://www.phu.bar/cgi-bin/");
document.write("count.pl?referrer=");
document.write(escape(document.referrer));
document.writeln(+ qt + gt);
//-->
</SCRIPT>
| [reply] [d/l] |