WordPress.org

Ready to get started?Download WordPress

Forums

Google Analytics Top Content Widget
[resolved] Top Viewed Content - Couple of Tweeks Needed (25 posts)

  1. supertrooper2
    Member
    Posted 1 year ago #

    Justin, your Google Analytics Top Content Widget has tremendous potential because it uses "rock-solid" data in the display.

    Many "Popular Post" plugins build data, which is unreliable and the results are really not credible.

    My question is whether it is possible to change the layout in the widget?

    1) Remove the Blue Bullets (see example how it looks on my blog http://focusingonwildlife.com/test-platform5/red-knot-in-winter-the-big-peep/

    2) List the "Top Viewed Content" without the rankings 1 to 10

    3) Include page hits in brackets after each item in the "Top Viewed Content"

    Hoping you'll be able to give me a fix for these issues.

    Please confirm.

    http://wordpress.org/extend/plugins/google-analytics-top-posts-widget/

  2. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    The styling of the output is all handled by your theme. Some themes neglect to add styling for the html ol (ordered list vs ul, unordered list) element, and that appears to be the case with your theme. The numerical display can all be handled through your theme stylesheet.

    Including page hits is a nice idea and something I'll look into adding in a future version of this plugin.

  3. supertrooper2
    Member
    Posted 1 year ago #

    Justin, I also tried to add the "Top Viewed Content" into my posts using the following code:

    [google_top_content pageviews=5 number=10 showhome=no time=2628000 timeval=2]

    The problem is that several pages showed up in the list including my top page: http://focusingonwildlife.com/news/ - My questions are

    1) how to limit the top-viewed content to posts only?
    2) how to exclude specific posts?
    3) how to include a title "Top-Viewed Posts" above the list with <h5>?

    Thanks in advance for your advice.

  4. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    1) limit content to posts:
    contentfilter=post (or pages: contentfilter=page)

    2) exclude specific post/page/content:
    postfilter=25 (use post ID, multiple exclusions doesn't work in the shortcode)

    3) Just add the h5 heading via the WordPress post edit screen above the shortcode

  5. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    All of the documentation for the optional filters are on the plugin page: http://wordpress.org/extend/plugins/google-analytics-top-posts-widget/

  6. supertrooper2
    Member
    Posted 1 year ago #

    Justin, I have adapted my shortcode based on your suggestions to:

    [google_top_content pageviews=5 contentfilter=post postfilter=23238, 26897,20233 number=10 showhome=no time=31536000 timeval=2]

    The "contentfilter" works fine but the "postfilter" doesn't seem to work with multiple posts. Is there a way to filter out more than one post?

    The "time=31536000" is equivalent to 1 month, so I'm a little confused what the purpose of the "timeval" is?

    Is there any way to filter out specific authors. e.g. posts published by myself under the "admin" name?

    Hoping you can help me on the above questions.

    Thanks in advance.

  7. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    You're right, as I mentioned, filtering multiple posts is not supported by the shortcode at this time. If you need to do something like that, I would suggest you filter by a category or exclude a category. The same goes for filtering by author.

    Your right, the timeval is superfluous in the shortcode.

  8. supertrooper2
    Member
    Posted 1 year ago #

    Justin, brilliant suggestion - the "catfilter" works perfectly when added into the html editor of a post. My shortcode is now as follows:

    <h3>Explore These Popular Posts</h3>
    [google_top_content pageviews=5 contentfilter=post postfilter=30681 catfilter=3173 number=20 showhome=no time=31536000]

    Please bear with me and advise on the following questions:

    1) where should the shortcode be added into a theme into have the list show up at the bottom of each post below the comments?

    2) is there a way to get the number of page views to show up in brackets after each item in the list?

    Hoping you have an answer on these issues.

    Thanks again for your advice.

  9. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    1) I'd use the WordPress function do_shortcode( '[YOURSHORTCODE]' );
    2) There are many filters in the plugin for ultimate flexibility. To do what you're requesting, you can put this code in your functions file.

    add_filter( 'gtc_pages_filter', 'gtc_add_viewcount_title' );
    function gtc_add_viewcount_title( $pages ) {
    
    	if ( !$pages )
    		return false;
    	// loop through the pages
    	foreach ( $pages as $key => $page ) {
    		// and add the page count to the title value
    		$pages[$key]['children']['value'] = $pages[$key]['children']['value'] . ' ['. $pages[$key]['children']['children']['ga:pageviews'] .' Views]';
    	}
    	return $pages;
    }
  10. supertrooper2
    Member
    Posted 1 year ago #

    Justin

    1) # page views - the second piece of code works great when added to the theme's "functions.php" file.

    2) shortcodes for all posts - I also tried adding the following code to the bottom of the theme's "functions.php" file:

    <?php do_shortcode('<h3>Explore These Popular Posts</h3>[google_top_content pageviews=5 contentfilter=post number=10 showhome=no time=2628000]'); ?>
    }

    Please advise what I've done wrong.

  11. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    <h3>Explore These Popular Posts</h3> is not part of the shortcode and should not be included. The code won't do anything if added to the functions file. You'll need to place it in the template file where you want it to appear.

    <?php echo do_shortcode( '[google_top_content pageviews=5 contentfilter=post number=10 showhome=no time=2628000]' ); ?>
  12. supertrooper2
    Member
    Posted 1 year ago #

    Justin, after trial and error I succeeded by adding the following code to my theme's "single.php" file:

    <?php echo do_shortcode('[google_top_content pageviews="5" catfilter="3173" contentfilter="post" number="10" showhome="no" time="2628000"]'); ?>

    Note the quotation marks ("") around all of the filter values. Without the quotation marks it doesn't work.

  13. supertrooper2
    Member
    Posted 1 year ago #

    Justin, many thanks for your outstanding support in getting this excellent plugin to function.

  14. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    Ok, glad to help.

  15. supertrooper2
    Member
    Posted 1 year ago #

    Justin, one more question on this topic if I may.

    I realized that the modification to the single.php file in my theme's folder is lost when the theme is updated. Therefore I tried to add the modified single.php file to the child folder of my theme.

    Unfortunately this doesn't seem to work. Please advise how to set-up the shortcode via the child folder.

    Thanks in advance for your advice.

  16. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    Did you create the child theme specifically for this purpose, or were you already using a child theme?

  17. supertrooper2
    Member
    Posted 1 year ago #

    There are approx 12 plugins with modifications on my site. Each time the theme was updated (approx one per month on average), I am forced to manually re-insert code into the plugins.

    Therefore I decided to install a child theme to save the hassle of these manual updates every few weeks. The biggest problem is that each plugin modification is different, and it becomes a challenge to remember what to insert into each plugin.

    The child theme is already working well for the style.css modifications, but for some reason the single.php file in the child folder doesn't seem to work.

    Please advise.

  18. Justin Sternberg
    Member
    Plugin Author

    Posted 1 year ago #

    I'm sorry, this is definitely outside the scope of this plugin. I'm not sure why it's not working for you. If you place a file, 'single.php' within your child theme folder, it should override the parent theme's 'single.php.' You may need to start a new general support thread, or file a support request with your theme provider.

  19. Contemplative Computing
    Member
    Posted 1 year ago #

    I love this. I had been using WordPress Popular posts but it was putting a huge strain on our server, especially during high traffic periods. This way there's no redundant counting going on and more accurate stats.

    I do need the view count visible in the widget. Our authors love being able to easily see their readership numbers. The list is much less useful without that feature. Any tips for hacking this in before I got at it myself?

    thanks,
    Matthew

  20. Contemplative Computing
    Member
    Posted 1 year ago #

    Nevermind. I somehow missed the solution you posted my first time through! Wonderful, thanks. Would be great if this was a built-in option. Man I never would have found that value on my own. :)

  21. Contemplative Computing
    Member
    Posted 11 months ago #

    Justin the filter you suggested seems to no longer work for adding a view counter in the newest version of the plugin (WP 3.6). Could you point us to what needs to change?

    Thanks,
    Matthew

  22. Justin Sternberg
    Member
    Plugin Author

    Posted 11 months ago #

    The filter I posted (http://wordpress.org/support/topic/top-viewed-content-couple-of-tweeks-needed?replies=21#post-3816989) still works for me. If it's not working for you, I'm not sure why.

  23. Contemplative Computing
    Member
    Posted 11 months ago #

    Got it working now. Strange. I think my problem has something to do with the plugin organizer plugin.

  24. Justin Sternberg
    Member
    Plugin Author

    Posted 11 months ago #

    Ok. Since you bumped both threads, please update the other thread as well.

  25. Satya Prakash
    Member
    Posted 9 months ago #

    I was expecting posts but it is giving me tag/* in popular posts. Is there a way to filter so that only posts are displayed?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.