Jump to content

Archived

This topic is now archived and is closed to further replies.

MommaTC

Link Tracking

Recommended Posts

I have looked through several hundred scripts and can't seem to find what I am looking for, I am hoping someone here will have an idea for me as to how to go about coding this.

I am using a PHP based e-mail autoresponder with a MySQL database.

I need to be able to create a "link tracking" type script that will send me an email with the subscribers name, e-mail adress, and what link they clicked, when they click on a link in an email I have sent them.

For example, let's say the subscriber receives my e-mail and clicks on "Link1"

The system will shoot me an email stating:

Subscriber ABC at myemail@email.net just visited Link1

Anybody have any thoughts on how to create a script that will do this?

Thank you,
Tracy

Share this post


Link to post
Share on other sites
personally i'd have setup like this,


You would have a php file that would be linked to a database, then each of the links inside the email would link to this php script with a unique id number (process.php?id=1),


so the php file (process.php for arguments sake)


//Process.php
[code]
<?php
require('db.php'); //Used to connect the database
require('mail_data.php'); //Used to make it easier to edit the email sent to you
$id = $_GET['id']; //Gets the supplied id number


$qry = mysql_query("SELECT * FROM links WHERE id='".mysql_real_escape_string($id)."'"); //Get any results that match the id address

$check = mysql_num_rows($qry);
if($check > 0){
$fetch = mysql_fetch_array($qry);
mail("myemail@email.net","Link Click",$mail_body,$mail_headers); //Sends you the email (set in mail_data.php)
//if you wanted you could also track links by updating the database on a click
//mysql_query("UPDATE links SET (click) VALUE('click+1') WHERE id='".mysql_real_escape_string($id)."'");
header("location: ".$fetch['url']); //This will redirect them to the sites actual link
exit();
}else{
//Do somthing if the id supplied isn't found in the database
header('location: google.co.uk); //simply redirects to google do what you like here (if anything)
}
?>
[/code]



//mail_data.php
[code]<?php
//I only do this because it's easier for you to change
//becuase i dont know how your  e-mail autoresponder  works with user data
//i cant add there name, you will have to do that your self.
$mail_body = "Somebody visited link ".$id. " you should replace this with the message your after";
$Mail_headers = "FROM: linkproc@system.com";

?>[/code]

hope it helps

Stuie

Share this post


Link to post
Share on other sites
what if you want to track the date time the email was read/openned by the user? Is it possible?

Let say when the user open their email client and reads the email. Is it possible to track this?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.