Go Back   CodingForums.com > :: Client side development > General web building

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-04-2012, 04:52 AM   PM User | #1
aarond9933
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
aarond9933 is an unknown quantity at this point
Question Tracking Link CLicks

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
aarond9933 is offline   Reply With Quote
Old 09-04-2012, 06:02 AM   PM User | #2
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
I believe you are looking for:
Google Analytics

Although I don't believe they track IP addresses, they do have event tracking:
Event Tracking

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:
PHP Code:
$ip $_SERVER['REMOTE_ADDR']; 
Javascript:
Code:
function tracker(i) {
     if(i == 1) {
          // code here
     }
     return true;
}
HTML:
Code:
<button onsubmit="return tracker(1)"></button>

Last edited by Sammy12; 09-04-2012 at 06:10 AM..
Sammy12 is offline   Reply With Quote
Old 09-04-2012, 06:11 AM   PM User | #3
aarond9933
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
aarond9933 is an unknown quantity at this point
Quote:
Originally Posted by aarond9933 View Post
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
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
aarond9933 is offline   Reply With Quote
Old 09-04-2012, 06:13 AM   PM User | #4
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
Use a cookie.

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

Code:
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:

Code:
function tracker(i) {
     if(i == 1) {
          count = getCookie("count");
          setCookie("count", count++, 7);
          alert(count);
     }
}
Code:
<button onclick="tracker(1)">Count</button>
edit: sec I need to test this

Last edited by Sammy12; 09-04-2012 at 06:27 AM..
Sammy12 is offline   Reply With Quote
Users who have thanked Sammy12 for this post:
aarond9933 (09-04-2012)
Old 09-04-2012, 06:35 AM   PM User | #5
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
I apologize, my previous code was incorrect, here is the full code:

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.

Last edited by Sammy12; 09-04-2012 at 07:16 AM..
Sammy12 is offline   Reply With Quote
Old 09-04-2012, 11:37 AM   PM User | #6
aaby07davis
New to the CF scene

 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
aaby07davis is an unknown quantity at this point
Mountain View Locksmith

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
Sanford FL Locksmith
San Francisco CA Locksmith
Locksmiths San Gabriel
aaby07davis is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:29 AM.


Advertisement
Log in to turn off these ads.