It could be fix using session, try following.
Initialize session using following code in your functions.php.
function init_sessions() {
if (!session_id()) {
session_start();
}
}
add_action('init', 'init_sessions');
add a function for setting session
function set_session_posts_viewed($postID)
{
if(empty($_SESSION['posts_viewed']))
{
$posts_viewed = array($postID);
$_SESSION['posts_viewed'] = $posts_viewed;
}
else
{
$posts_viewed = $_SESSION['posts_viewed'];
$posts_viewed[] = $postID;
$_SESSION['posts_viewed'] = $posts_viewed;
}
}
change post count updating code like this
function observePostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if(!isset($_SESSION['posts_viewed']) || (isset($_SESSION['posts_viewed']) && !in_array($postID, $_SESSION['posts_viewed'])))
{
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
set_session_posts_viewed($postID);
}else{
$count++;
update_post_meta($postID, $count_key, $count);
set_session_posts_viewed($postID);
}
}
}
Hope it fix the issue. Let me know if you have trouble.