WP Analytify Top Content Shortcodes

WP Analytify Top Content Shortcodes

An addon plugin to WP Analytify that adds new shortcode: analytify_top_content.

Why do I need it?

To show accurate most popular posts list without killing your server/database

Normally, top content / most popular posts are calculated by adding “+1” in database each time somebody visits certain post or page. This is fine, when there are not many visitors, but makes your database very busy once there are more visits. Caching? Either will stop counting of new visits, or will be passed by through javascript what will lead to heavy load again. But probably – as most of the sites – you’re using analytics. Right? And in analytics panel you can see most visited pages for certain date range. Why not use it instead of duplicating this existing feature on your website by yet another popular posts plugin? That’s exactly what we do here. To keep things simple and don’t repeat what was already done by numerous other plugins, we base our code on free WP Analytify plugin – this way you don’t have to authorize Analytics again if you’re already using it (... or you’ll get some extra analytics within WP admin panel once you install it).

How it works?

Shortcode allows users to fetch top pages from Google Analytics and show them as a list. Global options page allows you to exclude some particular pages across whole website if you’re using more than one shortcode on it. “Hostname” parameter was added to allow WPML / Polylang / other languages solutions work well (this way you can skip particular domain in particular place).

Technical details: when shortcode is fired – plugin will look for data stored in WordPress internal cache (transient). If no luck – new request through Analytify will fetch data from Analytics and keep it in transient for another visitors.

How will it look like?

It’ll be list of images and titles which should grab styles from your website. If there will be need for that – we’ll add predefined styles too, but we believe it’s better to keep it on theme side and leave styling to developers if needed. (if you’d need that – we offer custom development too, just let us know in comments)

How to use?

Available parameters:
  • period – defines time period we want to get (like: “2 months”, “last month”, “last 3 weeks”). Required
  • to – when period does not contain a word “last” we need to define point in time which is the last day of required period (so 2 weeks to 2018-12-01 is between 2018-11-14 and 2018-12-01)
  • limit – number of rows we want to show
  • exclude-home-page – pass “yes” if you want to exclude home page (which gets the most number of views usually) from results
  • post-type – required post type in results
  • title-remove – text we want to remove from the page title
  • except-ids – post IDs we want to skip from the result
  • except-urls – post urls we want to skip from the result
  • hostname – adds ability to filter by hostname (i.e. page in different language)

This plugin has global settings support for except-ids, except-urls and exclude-home-page options

Do you like this plugin?


**1.2 (2019-01-15)**
    * NEW: Global options for Top Content shortode (found in Analytify -> Settings -> Shortcodes global settings)

**1.1 (2019-01-14)**
    * NEW: Possibility to exclude certain post IDs or urls from appearing in the result
    * NEW: Ability to select base hostname from Google Analytics (i.e. for different language pages)

**1.0 (2018-12-27)**
    * First release

Support available in Polish and English!