How to get.. -
Hi!
Me again!
Im just wondering how via a CGI program, you can find out what domain a person came from before he/she came to your sites.
This is for a possible Statistics Program I may make.
I would have to get thet domain, than keep a list of domains in %domain with the keys as domains, and the number of people who came from that site as the value.
so I would do somthing like
$domain{$keys}=%domains;
if ($domain == $keys(%domains))
{
keys++;
}
Than a sort command like
$keys{$a} <=> $keys{$b}
Than a simple print the top 15 domains or whatever.
or somthing similiar to that? (as you can tell I haven't worked to much with Associative Arrays, so if someone can show me 'how to work' these arrays, that would be grateful )
THANKS!
Anonymous posted this at 23:28 — 9th May 1999.
They have: 5,633 posts
Joined: Jan 1970
maybe you shoud try this little script:
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Print Environment</title></head>
<body>
EndOfHTML
;
foreach $key (sort(keys %ENV)) {
print "$key = $ENV{$key}<br>\n";
}
print "</body></html>";
call it with your browser and it'll give you a list of all environment variables, just take out what you need....
Dass posted this at 23:50 — 9th May 1999.
They have: 109 posts
Joined: Apr 1999
Is the
HTTP_REFERER
what im looking for? is it the variable that gives the domain the person came from before the site?
Anonymous posted this at 00:43 — 10th May 1999.
They have: 5,633 posts
Joined: Jan 1970
Hi,
The HTTP_REFERER enviromental variable retrives the full url of the refering document (not just the domain).
You can still split up this variable to ge just the domain.
I'm not pretty sure, but I think it would be something like this:
Now you should have the domain stored in the $domain variable.
Hope this helps you.
------------------
Cheers
Polpus
http://wdresources.cjb.net
Anonymous posted this at 00:45 — 10th May 1999.
They have: 5,633 posts
Joined: Jan 1970
Sorry ... it should be $parts[2] instead of $parts[3].
Good luck
------------------
Cheers
Polpus
http://wdresources.cjb.net
Dass posted this at 23:08 — 10th May 1999.
They have: 109 posts
Joined: Apr 1999
Thanks for the help popus!
Im just wondering when doing
$referer = $ENV{'HTTP_REFERER'};
(@parts)= split(/\//,$referer);
$domain = $parts[2];
What 2 parts are actually being split?
and since im not too familiar with the split *thingy* , what does the /\// 'stand for'
Thanks!
Anonymous posted this at 16:16 — 11th May 1999.
They have: 5,633 posts
Joined: Jan 1970
<-- split the the string on /
every http url will have this form:
http://domain.topleveldomain/path
the text between the 2nd and 4rd / is always your domain.
There is a bug in that script though.
URLs have this general form protocol:path
Examples:
mailto:[email protected]
file:///c:/path
someProtocol:^^^&&%$#@are
These are all possible values of the http referrer and especially the 1st two are likely to appear in your log file.
So, you should check first whether the URL contains http and then make the split.
Later,
------------------
Malte Ubl
http://goKewl.com
Germany
anti posted this at 22:41 — 11th May 1999.
They have: 453 posts
Joined: Jan 1999
Hi,
the HTTP_REFERER gives you the name of the "calling" document.
So if you try to build your stats via a "cgi-image" (try http://webhome.nu/cgi-bin/wh.pl?wmf ) you'll get the URL of the page linking the image.
If your "index.html" is a CGI you've got a pretty good chance to get the real refering-url.
Otherwise you could try to extract the last-urls via JavaScript from the browser.
But that'll be a JavaScript question.
ciao
Anti
------------------
Visit my work in progress at
http://webhome.nu/
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.