I have complex php tracker where it stores user clicks etc.I am giving sample code here for pixel.php
session_start();
header('Content-type: image/png');
echo gzinflate(base64_decode('6wzwc+flkuJiYGDg9fRwCQLSjCDMwQQkJ5QH3wNSbCVBfsEMYJC3jH0ikOLxdHEMqZiTnJCQAOSxMDB+E7cIBcl7uvq5rHNKaAIA'));
        if (!isset($_SESSION['track']) || $_SESSION['track'] == '')
        {
        $_SESSION['track'] = "New User";
    //code to insert new user
        }
        else
        {
        $_SESSION['track'] = "Old User";    
    //codes to update old user
        }
Now I want to fire pixel when user clicks on my sign up forms or some bottons.So I use below code
  <script>
  function firepixel(val) {
    var img = document.createElement("img");
    img.setAttribute("src", "https://www.stimulatemind.com/track/pixel.php?id="+val);
    /* set other attributes here */
    document.body.appendChild(img);
  }
</script>
<script>
 $(document).on('click', '[data-pixel]', function() {
 var val = $(this).data("pixel"); 
firepixel(val);
}) ;
</script>
This code is working perfectly fine in desktops and ios , but for android chrome and few other browsers.New Session is created every time when the pixel.php is called.
I tried jquery $.get $.getJSON , etc , but everytime new session is created.
Any alternative or crossbrowser method to do this ? How to Google analytics does this ?
 
    