By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,409 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,409 IT Pros & Developers. It's quick & easy.

where do they go? How can I gather Click info in PHP

P: n/a
Hi Folk

I was wondering if it is possible to find out what people click on, using
PHP.

For example, I have a PHP page with an email link and some third party links
(e.g. www.someone-else.com). I want to know where people go.

My own solution would be to make the link not to an email or a third-party
website, but to another page along the lines of

<?php
//check out where it came from and where it is going
//write info to database
header = {where it should be going}


?>

I am not sure if you can do this with email, but I am also wondering if
there is an easier/smarter way to do this.

Cheers

- Nicolaas
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
windandwaves wrote:
I am not sure if you can do this with email, but I am also wondering
if there is an easier/smarter way to do this.


The header solution can only be used for normal links, not with email links
with the "mailto:" pseudo protocol.

But email links can, of course, link to an email form, so you can catch them
there.

Other solutions involve JavaScript, but you cannot rely on this because the
client can switch it off.
JW

Jul 17 '05 #2

P: n/a
Janwillem Borleffs wrote:
windandwaves wrote:
I am not sure if you can do this with email, but I am also wondering
if there is an easier/smarter way to do this.


The header solution can only be used for normal links, not with email
links with the "mailto:" pseudo protocol.

But email links can, of course, link to an email form, so you can
catch them there.

Other solutions involve JavaScript, but you cannot rely on this
because the client can switch it off.


Thank you for your answer, sounds like I may have to do something creative.

Cheers
- Nicolaas
Jul 17 '05 #3

P: n/a
Windandwaves

this is acutally rather easy.

the link that people click on should be something like:

<a href="/redirect.php?destinationURL=www.cnn.com">www.cnn.c om</a>
in redirect.php

you would code whatever is necessary to write the destination URL into the database and then redirect the visitor to the intended destination by doing:

header ('Location: '.$_REQUEST['destinationURL']);

that's all.

If you want to find out *where they come from* there is a variable called HTTP_REFER or something like that. Study the output of phpinfo(); to find the exact name.

There is a tutorial/article for exactly this called "where they went, where they came from" on
http://www.phpbuilder.com

Good luck!

GŁnther


windandwaves wrote:
Hi Folk

I was wondering if it is possible to find out what people click on, using
PHP.

For example, I have a PHP page with an email link and some third party links
(e.g. www.someone-else.com). I want to know where people go.

My own solution would be to make the link not to an email or a third-party
website, but to another page along the lines of

<?php
//check out where it came from and where it is going
//write info to database
header = {where it should be going}


?>

I am not sure if you can do this with email, but I am also wondering if
there is an easier/smarter way to do this.

Cheers

- Nicolaas

Jul 17 '05 #4

P: n/a
Guenther Schmidt wrote:
Windandwaves

this is acutally rather easy.

the link that people click on should be something like:

<a href="/redirect.php?destinationURL=www.cnn.com">www.cnn.c om</a>
in redirect.php

you would code whatever is necessary to write the destination URL
into the database and then redirect the visitor to the intended
destination by doing:
header ('Location: '.$_REQUEST['destinationURL']);

that's all.

If you want to find out *where they come from* there is a variable
called HTTP_REFER or something like that. Study the output of
phpinfo(); to find the exact name.
There is a tutorial/article for exactly this called "where they went,
where they came from" on http://www.phpbuilder.com

Good luck!

GŁnther


windandwaves wrote:
Hi Folk

I was wondering if it is possible to find out what people click on,
using PHP.

For example, I have a PHP page with an email link and some third
party links (e.g. www.someone-else.com). I want to know where
people go. My own solution would be to make the link not to an email or a
third-party website, but to another page along the lines of

<?php
//check out where it came from and where it is going
//write info to database
header = {where it should be going}



I am not sure if you can do this with email, but I am also wondering
if there is an easier/smarter way to do this.

Cheers

- Nicolaas

Thanks a lot GŁnther.
Jul 17 '05 #5

P: n/a
Guenther Schmidt wrote:
Windandwaves

this is acutally rather easy.

the link that people click on should be something like:

<a href="/redirect.php?destinationURL=www.cnn.com">www.cnn.c om</a>
in redirect.php

you would code whatever is necessary to write the destination URL
into the database and then redirect the visitor to the intended
destination by doing:
header ('Location: '.$_REQUEST['destinationURL']);

that's all.

If you want to find out *where they come from* there is a variable
called HTTP_REFER or something like that. Study the output of
phpinfo(); to find the exact name.
There is a tutorial/article for exactly this called "where they went,
where they came from" on http://www.phpbuilder.com

Good luck!

GŁnther

Here is what I did:

//link to database

$bot = browser_detection("type");
if(strlen($p) == 3){
$pageowner= $p;
}
if($h == 1) {
$httper = "http://".$pageownerwebsite;
}
elseif($h == 2) {
$httper = "http://".$pageownersecondsite;
}
else {
$httper = "http://www.myurl.co.nz/404.php";
}
$sqllog = 'INSERT INTO `LOG` ( `field1` , `field2` , `field3`, `field4` )
VALUES (NOW() , "'.$pageowner.'", "clicked","'.$httper.' ('.$bot.')" );';
$logger = mysql_query($sqllog);
$locationer = $httper;
header("Location: $locationer");

?>

It seems to be working well.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.