-1

I have a website that I would like to record on links clicked on each page. As an example, below is the code for my index.html page in which I attempt to record a link:

<a href="https://mystie.html/trackIndexPageLinks.php?token=1" role="button" tabindex="0">ADA</a>

Where "trackIndexPageLinks.php" is the name of my php file and "?token=1" is the php variable and value that I would like to record in my server.

Listed below is the php code that I use to store the value and pass it to my server:

<?php

$db_hostname = '???.?.?.?';
$db_database = 'mySiteDB';
$db_username = 'something';
$db_password = '';

$db_server = mysql_connect($db_hostname, $db_username, $db_password);

if(!$db_server) die("Unable to connect to MySQL:".mysql_error());

mysql_select_db($db_database)
    or die("Unable to select database: ".mysql_error());
echo @mysql_ping() ? 'true':'false';

$token = $_GET['token'];

//Create insert statement - inserts data into the database.
$sql = "INSERT INTO clickLog (linkClicked) 
VALUES ('$token')";

//Error check to ensure SQL statement took.
if (!mysql_query($sql)) {
    die('Error: ' . mysql_error());
}

//Close connection.
mysql_close();

?>

However, I get no recorded records. Any assistance on this would be greatly appreciated.

pol_guy
  • 457
  • 3
  • 8
  • 20

1 Answers1

1

You're much better off to sign up with google analytics and add snippets of javascript code they provide. They can give you complete detail as to who is linking to what on your page as well as what links they click as well as the order they click them in.

Go to: http://www.google.com/analytics/

All you need is a google account and if you don't have one, you can sign up for one. The whole thing is free.