Plugin / Google Analytics Top Content Widget




Adds a widget that allows you to display top pages/posts in your sidebar based on google analytics data.

Requires a Google Analytics account, and the plugin, “Google Analytics for WordPress by MonsterInsights” (which will be auto-installed by this plugin, thanks to @jthomasgriffin‘s awesome TGM Plugin Activation Class).

Also includes a shortcode to display the top content in your posts and pages.

Shortcodes with options supported:

  • Companion shortcode to widget
    [google_top_content pageviews=5 number=10 showhome=no time=2628000 timeval=2]
  • Display a post’s/page’s number of views
  • Conditional text where **count** will be replaced
    [google_analytics_views]This page has received count views.[/google_analytics_views]

Shortcode attributes definitions:

  • Pageviews: Show pages with at least __ number of page views
  • Number: Number of pages to show in the list
  • Showhome: Will remove home page from list: (usually “” is the highest viewed page)
  • Time: Selects how far back you would like analytics to pull from. needs to be in seconds. (1 hour – 3600, 1 day – 86400, 1 month – 2628000, 1 year – 31536000).
  • Time Value: time=2628000 timeval=2 like in the example above would be 2 months.
  • titleremove: Remove site title from listings. (Unless your site doesn’t output the site titles, then you will need to add this in order for the filter settings below to work.)
  • contentfilter: Limit listings to a particular post-type (post, page, etc)
  • catlimit: Limit listings to specific categories. (comma separated category ID’s)
  • catfilter: Remove listings in specific categories. (comma separated category ID’s)
  • postfilter: Remove specific posts/pages, etc by ID. (comma separated post ID’s)
  • thumb_size: Optionally display a thumbnail next to the post title (if the post has a thumbnail)
  • thumb_alignment: Thumbnail alignment — only applies if specifying a thumbnail size

All of the widget options are exactly that.. optional. If you don’t include them it will pick some defaults.

Plugin Features:

  • Plugin uses WordPress transients to cache the Google results so you’re not running the update from Google every time. cache updates every 24 hours.
  • Developer Friendly. Many filters built in to allow you to filter the results to dispay how you want. One example of that would be to remove your Site’s title from the results. (now unnecessary, as the widget/shortcode has the option built in)
    ** Example using a filter to add view counts after the title
    function gtc_add_viewcount_title( $pages ) {
    if ( ! empty( $pages ) ) {
    // loop through the pages
    foreach ( $pages as $key => $page ) {
    // and add the page count to the title value
    $pages[ $key ][‘name’] = $pages[ $key ][‘name’] . ‘ [‘. $pages[ $key ][‘value’] .’ Views]’;

    return $pages;

    add_filter( ‘gtc_pages_filter’, ‘gtc_add_viewcount_title’ );

Feel free to fork or contribute on Github.


The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.