Kind through Google Analytics (Utilities)

Sort by Google Analytics is a WordPress plugin that links up with your Google Analytics to add post sorting options based off your website’s usage statistics.

The plugin adds more sorting options to WP_Query’s parameters. This means you can easily use Sort by Google Analytics functionality wherever posts are queried in WordPress. Out the box, it comes with the extra orderby options: pageviews and visits. Some examples:


// Order posts by pageviews
$most_viewed_posts = get_posts( array(
    'orderby' => 'pageviews'
) );

// Order posts by most visited. Those with the same number of visits will be ordered by published date
$most_visited_posts = get_posts( array(
    'orderby' => 'visits date',
) );

You can also add your own sorting options based on Google Analytics metrics. For example, a fewest bounces sort option or by goal conversion rate. All of this is achievable with 10 lines of code and the most popular requests will be added to the plugin permanently.

Leave a Reply

Your email address will not be published. Required fields are marked *