Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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

  • #2
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #4
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    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.

  • Users who have thanked Sammy12 for this post:

    aarond9933 (09-04-2012)

  • #5
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    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.

  • #6
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •