diff --git a/README.md b/README.md index a0ddf4b5edab8c8a9f9b2c689816282bc2efcc0a..876fd2f4d04eb4222735a5797084fc47e69425a1 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,27 @@ Google Analytics Page Stats =========================== Google Analytics Page Stats is a [WordPress](https://wordpress.org/) plugin to -access Google Analytics for singular pages in a WordPress installation. +access Google Analytics for pages in a WordPress installation. You need to set up the [necessary tracking for Google Analytics](https://support.google.com/analytics/answer/1008015). Also, you need to [enable the Google Analytics API and create a service account and a JSON -key](https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-php). +key](https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-php) +for the plugin to use. -After activating the plugin, configur the View ID and the JSON key, and the -stats will appear at the bottom of each singular page in your WordPress -installation when you access it as administrator. +After activating the plugin, configure the View ID and the JSON key, and (if you +enable to show by default) the stats will appear at the bottom of each singular +page in your WordPress installation when you access it as administrator. + +You can disble this, and insert your own PHP code in your theme or widget to +retrieve the page stats and show them as you whish. + +``` +require_once(GA_PAGE_STATS__PLUGIN_DIR . 'class.ga-page-stats.php'); +$r = GAPageStats::getPageStats($_SERVER['REQUEST_URI']); +$spv = number_format($r[0]); +$su = number_format($r[1]); +``` + +At the moment, the plugin retrieves the PageViews (`ga:pageView`) and Users +(`ga:users`) stats for a tracked path.