title: Difference in no of visits in Google analytics reports and page counter
body: <p>Hi i have a website <a href="https://www.ludhianaweddings.com" rel="nofollow noreferrer"><strong><em>Link</em></strong></a> in which i have inserted Google analytics code for daily reports. I also have inserted an Update query on each of my web page that is updated by 1 each time a page is visited.</p>
  
  <p><strong>Query</strong></p>
  
  <pre><code>$date= date("Y-m-d");
  $count=1;
  
  if ($stmt = $mysqli-&gt;prepare("SELECT *,count(*) as cnt FROM Table WHERE date=?")) {
      $stmt-&gt;bind_param('s',$date);
      $stmt-&gt;execute();
      $res = $stmt-&gt;get_result();             
      $row = mysqli_fetch_array($res);
      $cnt= $row['cnt'];
      if($row['cnt']==1){
          $count=$row['count']+1;
          $stmt = $mysqli-&gt;prepare("UPDATE Table SET counts='$count' WHERE date=?");
          $stmt-&gt;bind_param('s',$date);
          $stmt-&gt;execute();
      }else{
          $stmt = $mysqli-&gt;prepare("INSERT INTO Table VALUES('',?,?)");
          $stmt-&gt;bind_param('ss',$date,$count);
          $stmt-&gt;execute();
      }
  }
  </code></pre>
  
  <p><strong>Google Analytics code</strong></p>
  
  <pre><code>&lt;script&gt;
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  
    ga('create', 'UA-103015467-1', 'auto');
    ga('send', 'pageview');
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Now when i check both at morning, It shows a huge difference in daily visits. Reports of last 4 days are as </p>
  
  <pre><code>Date        G.Ana   UpdtQuery
  
  2-Aug       70      489
  3-Aug       59      581
  4-Aug       46      1240
  5-Aug       71      611
  6-Aug       37      508
  7-Aug       58      1189
  </code></pre>
  
  <p>Why there is a lot of difference in Google Analytics reports and visits counted by update query ??
  Thanks in Advance...</p>