This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

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.


  • Widget options.
  • Widget display (in an ordered list).


  1. Upload the google-analytics-top-posts-widget directory to the /wp-content/plugins/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. Plugin will prompt you to install the “Google Analytics for WordPress by MonsterInsights” plugin. Install and activate it.
  4. Use the “Google Analytics for WordPress by MonsterInsights” plugin’s settings page to authenticate to your google analytics account.
  5. On the widgets page, drag the “Google Analytics Top Posts” widget to the desired sidebar.
  6. Update the widget settings and save.


After Upgrading to 1.4, my widget stopped working

I updated the widget options for the date picker, and as a result, it broke any widgets that were saved with the old options. 1.4.1 solves that, but either way, re-saving the widget will correct the issue.

If you were using the shortcode and it broke, you will need to switch to using the shortcode with the new format (described here)

Is it possible to configure the metric being sent to GA, for example to use uniques (ga:uniquePageviews) instead?
Can I display the analytics count next to the title?
Can I blacklist certain pages/urls from showing?
Can I blacklist certain pages/urls from showing if the path begins with “/exclude/”?
I also want to add the page excerpt to the list item. Is that possible?

If you run into a problem or have a question, contact me (contact form or @jtsternberg on twitter). I’ll add them here.


For some reason it will not Filter Out Post/Page IDs

I inserted a few post ids (separated with only a comma) under “Filter Out Post/Page IDs:” but it does not filter them. They still show up in the top content widget.

Please fix ASAP or tell me how to fix. I don’t want certain posts to be shown in the list.

Excellent support

At a glance, this plugin seems to lack customization. But once you know how to do it, it really works flawlessly.

Even if you don’t, you can! This plugin deserves 5 star not only because it works great, but also because of the excellent support from Justin, the plugin developer. He replies really fast and efficient. Thanks Justin!

Works perfectly!

Google Analytics has been great for getting my blog off the ground and running. It was the perfect for keeping me organized, and doesn’t create any overly-complicated or unnecessary process. Super responsive support as well!

[link removed]

Read all 9 reviews

Contributors & Developers

“Google Analytics Top Content Widget” is open source software. The following people have contributed to this plugin.




  • Fixes fatal errors caused by an update to the dependency plugin, “Google Analytics for WordPress by MonsterInsights”. With the last release, they moved to only loading some resources in the admin, so we need to lazy load those resources on the frontend if they don’t exist.
  • Allow comma (1,2,3) or comma-space (1, 2, 3) separated ids for the widget/shortcode settings for the category id filters and the post/page filter.


  • Fix Check for “Google Analytics for WordPress by MonsterInsights” plugin when displaying widget settings


  • Update to support MonsterInsights > 6.0. Props @chriscct7, #18.
  • Pass thumbnail to gtc_list_item filter and counter to the list_item_format sprintf. Props @chibani, #12.
  • By default, filter out posts which are not published (e.g. drafts, pending). Props @pmtarantino, #15.
  • Support for non-ascii urls in google_analytics_views shortcode, and new filter, gtc_views_shortcode_ga_filters_param. Props @entr, #21.
  • New filter, gtc_should_display_item, to override whether an item should be added to the list.
  • No longer output an empty link when thumbnails are enabled, but not found.


  • Fix the issue which allowed some content through which should have been disallowed by the content filter. Now if the content filter is used at all and url_to_postid fails, the page will be excluded in the results.


  • Tweak logic for homepage checking, and also check for paginated homepage entries.
  • Fix the category limit filter in the widget settings.


  • Fixes “PHP Fatal error: Class ‘Yoast_Api_Google_Client’ not found” errors when trying to save posts with the shortcode.


  • Use url_to_postid() to properly fetch a post ID from a url. Support thread.


  • Switch the content filter to a multi-check field, and allow multiple post-type selections. Props @pmtarantino, #9.



  • Bug fix: “Google Analytics by Yoast” version 5.4.3 changed the name/location of their Google Analytics client class, so need to compensate


  • Update TGM-Plugin-Activation library.
  • Cause shortcode caches to be flushed when the post is updated.


  • New filters, ‘gtc_analytics_request_params’, and “gtc_analytics_{$context}_request_params” for modifying the request arguments to the Google Analytics API. (for things like this)


  • Replaced dependency on ‘Google Analytics Dashboard’ plugin with a dependency on ‘Google Analytics by Yoast’
  • New filters, ‘gtc_list_format’ and ‘gtc_list_item_format’ for modifying the format of the list/list-item output


  • Update for xss vulnerability,


  • Feature: Add thumbnail option to widget.


  • Bug Fix: Fix a few logic issues causing debug.log notices.


  • Bug Fix: Use a unique transient ID for every shortcode instance.


  • Bug Fix: update=true shortcode parameter (used for busting the cache) did not work properly.


  • Bug Fix: Fix a couple filters that were getting false-postives.


  • Bug Fix: Renamed the widget in 1.5.0 which would cause it to be unregistered in any sidebars. Quickly pushed up an update to put it back, but this release makes it final. Apologies for the inconvenience.


  • Enhancement: New shortcode, google_analytics_views for displaying a view count on a single post/page.


  • Bug fix: Now there is a unique transient for each widget instance.


  • Improvement: By default won’t list duplicate urls with query variable strings (often generated by sharing applications).


  • Bug fix: Listings wouldn’t show when using ‘post’ as the contentfilter.


  • Enhancement: More output filters, and check for ‘?p=’ permalinks


  • Enhancement: Allow html in list item output


  • Bug fix: Some entities would break the “remove site name” filter.


  • Fixed the number value select for the “Select how far back you would like analytics to pull from:” selector.


  • I updated the widget options for the date picker, and as a result, it broke any widgets that were saved with the old options. 1.4.1 solves that, but either way, re-saving the widget will correct the issue.

If you were using the shortcode and it broke, you will need to switch to using the shortcode with the new format (described here)


  • Added more flexibilty to the time select dropdown. Now with options to select hours and days.


  • Added more widget options to modify the list output. Added field to enter repeating elements in the titles to remove from the listings. Also, now limit or filter by post-type, by category, or by post/page ID.


  • Increased page-speed with use of transients caching. Also added a few more developer friendly filters.


  • Add a pages filter for developers, remove site title from page title, change date picker to use relative dates.


  • Launch.