Commit ce7465da authored by Canek Peláez's avatar Canek Peláez
Browse files

Explain how to use the GAPageStats class.

parent c896e322
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -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.