Title: Retrieving pageviews in a PHP variable
Last modified: December 31, 2016

---

# Retrieving pageviews in a PHP variable

 *  Resolved [paristocrate](https://wordpress.org/support/users/paristocrate/)
 * (@paristocrate)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/retrieving-pageviews-in-a-php-variable/)
 * Hey.
 * I want to save every 60 minutes the pageviews in the post metadata.
    How can 
   I get the pageviews count in a PHP variable ?
 * A code snippet would be welcome 🙂
    Txs !

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Gennady Kovshenin](https://wordpress.org/support/users/soulseekah/)
 * (@soulseekah)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/retrieving-pageviews-in-a-php-variable/#post-8606074)
 * Hey there.
 * The whole point of the plugin is to never do anything on the PHP side, for performance
   reasons. That said, you can certainly use the API: [https://pv.pjtsu.com/](https://pv.pjtsu.com/)
 * JavaScript AJAX calls [https://github.com/pressjitsu/pageviews/blob/master/pageviews.js](https://github.com/pressjitsu/pageviews/blob/master/pageviews.js)
   can all be done via wp_remote_get/post if needed. Should be pretty straightforward.
 * If you need something more specific do tell, we’ll be glad to help you out here
   🙂
 * Cheers and happy holidays.
 *  Thread Starter [paristocrate](https://wordpress.org/support/users/paristocrate/)
 * (@paristocrate)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/retrieving-pageviews-in-a-php-variable/#post-8607547)
 * Thank you very much.
    Yes, I understood that it was the idea… but I just need
   to extract this number for an algorithm used on our site…
 * Happy new year!
 *  Plugin Author [Gennady Kovshenin](https://wordpress.org/support/users/soulseekah/)
 * (@soulseekah)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/retrieving-pageviews-in-a-php-variable/#post-8608627)
 * Then use `wp_remote_get` on `https://pv.pjtsu.com//v1/get/key1[,key2[,...]]` 
   etc. where keys are simply `post_ID`s. Makes sense? Don’t forget the X-Account
   header which you can find out in the `wp_options` table under the `pageviews_config`
   option name.
 * Also check out [https://github.com/pressjitsu/pageviews-widget/blob/master/pageviews-widget.php](https://github.com/pressjitsu/pageviews-widget/blob/master/pageviews-widget.php)
   our Widget which does interact with our API via PHP for more example code.
 * Let us know if there’s anything else you need to know.
    -  This reply was modified 9 years, 5 months ago by [Gennady Kovshenin](https://wordpress.org/support/users/soulseekah/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Retrieving pageviews in a PHP variable’ is closed to new replies.

 * ![](https://ps.w.org/pageviews/assets/icon-256x256.png?rev=1451114)
 * [Pageviews](https://wordpress.org/plugins/pageviews/)
 * [Support Threads](https://wordpress.org/support/plugin/pageviews/)
 * [Active Topics](https://wordpress.org/support/plugin/pageviews/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pageviews/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pageviews/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Gennady Kovshenin](https://wordpress.org/support/users/soulseekah/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/retrieving-pageviews-in-a-php-variable/#post-8608627)
 * Status: resolved