keep the record of the number of clicks on an external link or internal link on the page
<p>I try to implement the following code:</p>

<pre><code>  &lt;a href = "http://www.google.com"/ id="external"&gt;go to google&lt;/a&gt;
   &lt;span  id="num1"&gt;&lt;/span&gt;// to show the number of clicks so far.
  &lt;a href = "index.php" id="internal"&gt;go to home&lt;/a&gt;
  &lt;span id="num2"&gt;&lt;/span&gt;&gt;// to show the number of clicks so far.


&lt;script&gt;
  $(document).ready(function() {
    var count1=0;
    var count2=0;
    $("#external").click(function(){
        count1++;

   });
 $("#num1").html(count1);
    $("#internal").click(function(){
        count2++
   });
  $("#num2").html(count2);

  });

&lt;/script&gt;
</code></pre>

<p>I am not sure what I did above is right for the purpose of keeping track of the number of clicks on each link, and the problem is that when the page is loaded again, the count variable will be reset to 0, I wonder if I need to insert the count variable into database or is there even more efficient way to do this, any one could help me with that, any help will be greatly appreciated!</p>
