...

View Full Version : Tracking Link CLicks



aarond9933
09-04-2012, 05:52 AM
Hey I was wondering if you guys new of any way to add something to your website which showed the current IP address how many times they have clicked on a certain link.
not total link clicks but just for that person.

Or alternatively if there is some sort of app or something that does something along these lines.


Let me know what you got,

Thanks
AaronD:confused:

Sammy12
09-04-2012, 07:02 AM
I believe you are looking for:
Google Analytics (http://www.google.com/analytics/)

Although I don't believe they track IP addresses, they do have event tracking:
Event Tracking (https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide)

I'm assuming they don't have it since there is no real reason to track how many times a particular IP Address clicked something.
Unless it was for something shady...

You could also code one yourself using:

PHP:


$ip = $_SERVER['REMOTE_ADDR'];


Javascript:


function tracker(i) {
if(i == 1) {
// code here
}
return true;
}


HTML:


<button onsubmit="return tracker(1)"></button>

aarond9933
09-04-2012, 07:11 AM
Hey I was wondering if you guys new of any way to add something to your website which showed the current IP address how many times they have clicked on a certain link.
not total link clicks but just for that person.

Or alternatively if there is some sort of app or something that does something along these lines.


Let me know what you got,

Thanks
AaronD:confused:

I probably didn't make this clear, I'm trying to make it so that the person viewing the website knows how many times they have clicked on a l certain link, I know its unusual, LOL but needed.


Thanks
AaronD

Sammy12
09-04-2012, 07:13 AM
Use a cookie (http://www.w3schools.com/js/js_cookies.asp).

I don't remember where I got this code from, but I found it on my computer:



function setCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(";");
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==" ") c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}


so it would be:



function tracker(i) {
if(i == 1) {
count = getCookie("count");
setCookie("count", count++, 7);
alert(count);
}
}




<button onclick="tracker(1)">Count</button>


edit: sec I need to test this

Sammy12
09-04-2012, 07:35 AM
I apologize, my previous code was incorrect, here is the full code:



<!DOCTYPE html>
<html>
<head>
<script>
function setCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(";");
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==" ") c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

count = getCookie("count");
if(count == false) {
setCookie("count", 0, 7);
}
function tracker(i) {
if(i == 1) {
setCookie("count", count++, 7);
document.getElementById("count").innerHTML=count;
}
}
</script>
</head>
<body>
<button onclick="tracker(1)">Hit Me</button>
<div id="count"></div>
</body>
</html>


Feel free to click on the button as much as you want, it will continue to increment as you press the button.

You can also use jQuery cookie which is much simpler, but I think learning JavaScript first is better.

aaby07davis
09-04-2012, 12:37 PM
Excellent particulars, outstanding details! I have been really fortunate by you and you've got really done a great job. and one more thing I'm searching for discussion boards who have really great advice on what exactly is popular and also what are the very best makeup is actually.
Locksmiths Rowlett (http://RowlettLocksmith.bestfriscolocksmith.net )
Sanford FL Locksmith (http://SanfordLocksmith.trustedlocksmith.net )
San Francisco CA Locksmith (http://SanFranciscoLocksmith.my3gb.com )
Locksmiths San Gabriel (http://SanGabrielLocksmith.EconomicalService.com )



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum