=== Toplytics === Contributors: PressLabs Donate link: http://www.presslabs.com/ Tags: presslabs, analytics, posts, top, most visited, most viewed posts, top content, toplytics, popular, google analytics, high traffic, popular posts, oauth, server resources, settings, widget, embed code, javascript, json, json file, simple, post views Requires at least: 3.9 Tested up to: 4.5 Stable tag: 3.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Displays the most visited posts as a widget using data from Google Analytics. Designed to be used under high-traffic or low server resources. == Description == This plugin displays the most visited posts as a widget using data extracted from Google Analytics. It is designed to work with high-traffic sites and all types of caching. = IMPORTANT! = You need to have Google Analytics active on your site if you want to use this plugin! = Features = * Shortcodes are now supported for easier integration into posts/pages or other widgets. `[toplytics period="week" numberposts="3" showviews="true"]` Check FAQ for details; * Connection with Google Analytics Account using OAuth 2.0 method; * Starting with the plugin version 3.0 we have switched to GA API v3 * Offers a widget displaying the most visited posts as simple links (no styling); * The widget can display the most visited posts from the past day, week or month; * You can set the number of posts to be displayed between 1 and 250; * It can also display the number of views as counted by Google Analytics; * i18n support/translation requests are more than welcome; * Generate the list of the most visited posts dynamicaly with JavaScript to correctly display them with any caching mechanism/plugin; * Custom template for displaying the widget is available and should be included in the active theme folder; * You can use some of the plugin's functions if the above are not enough for your customization needs. Check FAQ for details; == Installation == = Installation = 1. Upload *toplytics.zip* to the */wp-content/plugins/* directory; 2. Extract the *toplytics.zip* archive into the */wp-content/plugins/* directory; 3. Activate the plugin through the *Plugins* menu in WordPress. Alternatively, go into your WordPress dashboard and click on *Plugins -> Add Plugin* and search for Toplytics. Then click on *Install*, then on *Activate Now*. = Configuration step 1 = In this step please register a new client application with Google. To register an application please login to your Google account and go to Google API console. 1. Create a New Project (set a unique project name and id); 2. Enable the Analytics API by going to APIs & auth → API → Analytics API and then click on *Enable API*; 3. From the APIs → Credentials tab create an OAuth 2.0 Client ID by clicking on *Create new Client ID*; 4. Select application type as *Installed application*; 5. Create the Branding information for the Client ID by editing the consent screen. It's compulsory to select your e-mail addres and to set a Product name; 6. Create the Client ID by selecting again *Installed application* and *Other*; 7. Download the JSON file with the API credentials (Auth Config file); 8. Upload this file in the plugin Settings page and click on *Upload Auth Config File*. = Configuration step 2 = In this step please connect to your Google Analytics Account. 1. Click the *Get Authorization Key* button from the plugin's settings page and you will be redirected to google.com; 2. After logging in you need to agree that the newly created app will access your Analytics data. After that you get a key; 3. Then come back to the plugin settings page and use the key in the *Authorization Key* field. Click on *Get Analytics Profiles* button, select the profile for your current site and click on *Connect*. = Usage = Connect your plugin with Google Analytics Account from the Settings page (*Settings -> Toplytics*); Use the *Toplytics* widget from the *Appearance -> Widgets* page; == Frequently Asked Questions == = Why should I use this plugin? = You should use this plugin if you want to display the most visited posts of your site in a safe and stable manner, with no risk of downtime or slowness, based on data from Google Analytics statistics. The plugin is built for high-traffic sites where counting every visitor's click loads up the DB and can potentially crash the site. = How often is the data from Google Analytics refreshed? = The data from GA is refreshed every hour. During this interval, the information is safely stored using transients and options. = How to use the custom template? = To use a custom template you just need to copy the file `toplytics-template.php` from Toplytics' plugin folder to your theme folder. You can then customize your template. The plugin will first search for the file `toplytics-template.php` in the active theme folder, and, if that's not found, it will search for it in the plugin folder. The custom template from the theme folder has priority over the one in the plugin folder. = How can I use the shortcode? = The shortcode has 3 parameters: period -> default=month (today/week/month), numberposts -> default=5 (min=1/max=250), showviews -> default=false (true/false) Shortcode example: `[toplytics period="week" numberposts="3" showviews="true"]` The shortcode can be used within post/pages and in other widgets from the sidebar. For any parameter that is not used, the default value will be used. = How can I use JavaScript code in order to show up the top in widget? = You can place the JavaScript code right in `toplytics-template.php` file or use a predefined JS code like this: `` The `toplytics_args` are the options from the current widget passed to the template. For a detailed example see the JavaScript code from `js/toplytics.js` file. = How can I use the plugin functionality outside the sidebar? = The plugin offers 2 functions that can be used either in the theme or by another plugin. Please review the complete documentation below. **1.** `toplytics_results` **Description** `mixed toplytics_results( [ array $args ] )` toplytics_results() prints the toplytics results in `