I want to track my prospects from which URL(like fb, g+ or mailer) they have visited my website.This is all is for understanding visitor for better digital marketing.
My Fiddle: http://jsfiddle.net/dSp4g/
Please help me with code as below
Thanks in advance
HTML
<div class="form-group">
<label for="exampleInputEmail">Full name</label>
<input type="text" class="form-control " id="exampleInputName" placeholder="Enter your full name" style="color:#000 !important;">
</div>
<div class="form-group">
<input type="hidden" class="form-control " id="sourcecode">
</div>
<div class="form-group last">
<button class="mailbtn">Submit</button>
</div>
JS
$('.mailbtn').live('click',function(){
name = $('#exampleInputName').val();
sc = $('#sourcecode').val();
$(document).ready(function() {
if (sourcecode = $.parsequery().s)
{
$("#source").val(sourcecode); }
});
$.ajax({
type: "POST",
async : false,
url: "mail.php",
data: { name:name, sourcecode:sc}
})
.done(function( msg ) {
$('.mail_middle').html('');
$('.mail_middle').html('We will call you to confirm your delivery address.Thank you.');
return false;
});
});
mail.php
<?php
$to = array("my_email1","my_email2");
$message .= "<table border='1'>";
$message .= "<tr><td>Name </td><td>".$_POST['name']."</td></tr>";
$message .= "<tr><td>Source </td><td>".$_POST['sc']."</td></tr>";
$message .= "</table>";
$headers = "MIME-Version: 1.0
";
$headers .= "Content-type: text/html; charset=utf-8
";
$headers .= 'from: '.$from .'' . "
" .
'Reply-To: '.$from.'' . "
" .
'X-Mailer: PHP/' . phpversion();
foreach($to as $row)
{
mail($row,$subject,$message,$headers);
}
echo "Mail Sent.";
die;
?>