Nodejs real time online user counter

I have a website and implemented a real time online user counter using nodejs and socket.io. Here is the code:

$io.on('connection', function (socket) {

    var $ip_address = socket.handshake.address;
    if ($ips_connected.hasOwnProperty($ip_address)) {
        $ips_connected[$ip_address]++;
    } else {
        $ips_connected[$ip_address] = 1;
        $connected_users++;


        if ($connected_users > $max_users)
            $max_users = $connected_users;
    }

    socket.emit('update', $connected_users);

    socket.on('disconnect', function () {
        if ($ips_connected.hasOwnProperty($ip_address)) {
            $ips_connected[$ip_address]--;
            if ($ips_connected[$ip_address] <= 0) {
                delete $ips_connected[$ip_address];
                $connected_users--;
            }
        }
    });

    socket.on('update', function () {
        socket.emit('update', $connected_users);
    });

});

As you can see, i do not consider multiple conections by the same ip address. The problem with this code is that Google Analytics Real Time data are showing a number smaller than that calculate by nodejs.

What i need is a explanation of someone who have already implemented something like this using nodejs to tell me if i can trust on this code or should i trust on Analytics real time counter. I'm showing to my users the number of users connected to my website at the moment using this code, so i dont want to display wrong numbers.

UPDATE

I forgot to say that analytics are showing numbers like 30 units less than my own counter.

I have seen scenarios in certain browsers like IE8, IE6, and others that can't remember... where it is common to socket.io break the connection and restart automatically without invoking the disconnect. My suggestion for you is to generate an unique id for each connection to control if that is really a new connection.