Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/9278-link-tracking/
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
Link to comment
https://forums.phpfreaks.com/topic/9278-link-tracking/#findComment-34254
Share on other sites

  • 5 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.