Since it appears you want to track each kind of page view (which is what Google Analytics would do for you if you don’t want to roll your own), then create a function that will use the current page-type, or even any type of page.
A function like (rough code)
function record_view($pagetype="post") { // function with default value
switch ($pagetype ) {
case "post":
//do something
break;
case "page":
// do something for a pge
break;
// add additional cases for whatever you are trackin
case default:
// do something if not any of the above types
break;
}
return;
}
See this page in the Codex for info about page types: https://codex.wordpress.org/Post_Types .
Then put a call for the function in the template of the various page types
record_view('post'); // this on the single post template
That might get you started, if I understand your question and comments correctly.
Good luck!