How we can keep tracking a link using Javascript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How we can keep tracking a link using Javascript?

I want to keep track link as user click on it and see how many times is get clicked by user is an <a> with link on it

25th Mar 2020, 7:38 PM
Sofian Bekkari
Sofian Bekkari - avatar
8 Answers
+ 2
For that will be needed for example PHP language. Then you can keep the number of clicks in a file (for example .txt). With each click the file will be updated. You need the tutorial as follows: https://www.sololearn.com/learn/PHP/1846/
25th Mar 2020, 9:54 PM
JaScript
JaScript - avatar
+ 1
You could use local storage..... No need of PHP
26th Mar 2020, 2:15 PM
Fbn 76
Fbn 76 - avatar
+ 1
Thanks guys! I will try out
28th Mar 2020, 9:52 AM
Sofian Bekkari
Sofian Bekkari - avatar
0
I am not very good at js But according to my sense the code something like that : let count = 0; $('a').onclick(() => count++); onclick is event listener $ is jquery selector inside event listener there is an es6 function
25th Mar 2020, 7:44 PM
Mr Robot
Mr Robot - avatar
0
Thank you brother! is look so simple and light code, But there other issues I'm not mention it is how to stored value for example to google sheet or somewhere else when I can see it ?
25th Mar 2020, 8:16 PM
Sofian Bekkari
Sofian Bekkari - avatar
0
I don't understand your question well But if you store the no of times the link clicked you can also display it. In variable case using console or alert For google sheet or other there May be some other procedure
25th Mar 2020, 8:28 PM
Mr Robot
Mr Robot - avatar
0
Thanks Saad for your help anyway :)
25th Mar 2020, 8:49 PM
Sofian Bekkari
Sofian Bekkari - avatar
0
Sofian Bekkari welcome I hope some one good may help you
25th Mar 2020, 8:51 PM
Mr Robot
Mr Robot - avatar