Almost everyone who has a WordPress site/blog, uses Google Analytics. This great tracking tool gives you insight into your visitors that traditional marketers would only dream of. Sometimes you want to do some things that Google Analytics is not a right fit for. You may want to track which pages or posts are the most popular.
Below is a function that you can put in your functions.php file.
Once you have done this, be sure to put the yab_post_view_counter() somewhere in your post.php or page.php file. From now on, you’ll be able to call and sort all your posts by this meta value, or create a widget that shows the most popular post and/or pages. No plugins required!