473,396 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
5 1845
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: carrionk | last post by:
Hi, I'm currently working with a Legacy System whose only output is pivot tables in Excel. If I need certain data, I change the pivot table to get the information I want. All the info is...
0
by: **Developer** | last post by:
I know this is not the correct NG but I've been trying to get this answered for a while and can't find someone really knowledgeable about printers. (Actually it does relate to something I'm...
2
by: Joseph | last post by:
Has anyone had any experience gathering the local computername through a web application with no client side program. I've been researching different avenues and have been coming up blank so far. ...
2
by: MLH | last post by:
Say I'm walking a subset of the records in tblAddnlOwners via DAO. Suppose there are 5 records in the extract and that I MoveFirst, MoveNext and MoveNext. Then, when on the 3rd of 5 records, I...
10
by: Henry Jones | last post by:
I am using VB.NET 2005 and built and published my solution. When installing on a clients PC, where does the EXE go? Assume my project is Test. Shouldn't it be installed in C:\Program Files\Test ?...
5
by: Michael.Suarez | last post by:
Suppose I have a button on a form that opens up another form. the code in the buttons click event is: frmMyCustomForm frm = new frmMyCustomForm (); frm.ShowDialog(); frm.Dispose(); The...
3
by: rrstudio2 | last post by:
If I have two tables and need to do a left outer join and include a where statement on the second table, it seems like the left outer join becomes an inner join. For example: Table: Names id...
0
by: dhanu sahu | last post by:
I am entering Day,LoginId,Name,Checkin time,Check Out Time In TextBox and A SUBMIT button Twist Is : Once User Click Submit>>>> It can not be Editable Again Either refreshing or Using IE ...
2
by: Laurence | last post by:
Hi folks, My database DB03 is circular logging. I called the db2 procedure: get_dbsize_info to get the database size as below: Parameter Name : SNAPSHOTTIMESTAMP Parameter Value :...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.