Connecting Tech Pros Worldwide Help | Site Map

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

windandwaves
Guest
 
Posts: n/a
#1: Jul 17 '05
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


Janwillem Borleffs
Guest
 
Posts: n/a
#2: Jul 17 '05

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


windandwaves wrote:[color=blue]
> 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.
>[/color]

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



windandwaves
Guest
 
Posts: n/a
#3: Jul 17 '05

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


Janwillem Borleffs wrote:[color=blue]
> windandwaves wrote:[color=green]
>> 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.
>>[/color]
>
> 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.
>[/color]

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

Cheers


- Nicolaas


Guenther Schmidt
Guest
 
Posts: n/a
#4: Jul 17 '05

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


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:[color=blue]
> 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
>
>[/color]
windandwaves
Guest
 
Posts: n/a
#5: Jul 17 '05

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


Guenther Schmidt wrote:[color=blue]
> 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:[color=green]
>> 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}
>>
>>
>>
>>[color=darkred]
>>>[/color]
>>
>> 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[/color][/color]


Thanks a lot Günther.


windandwaves
Guest
 
Posts: n/a
#6: Jul 17 '05

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


Guenther Schmidt wrote:[color=blue]
> 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[/color]


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.


Closed Thread