plausible / wordpress

Plausible Analytics WordPress plugin
https://plausible.io/wordpress-analytics-plugin
MIT License
52 stars 26 forks source link

Show Analytics for posts #148

Open ThomasTr opened 1 year ago

ThomasTr commented 1 year ago

It would be nice to show analytics for each post from backend posts page. Either as a link to plausible installation, or as a async loading overlay or as page within wordpress backend.

Actually the way is to copy the uri and filter for it in plausible.

oliveratgithub commented 1 year ago

I really like the idea! 💯

Extended my WP Plausible API proof-of-concept with a Demo of such a Plug-in 😎 https://github.com/oliveratgithub/plausible-api-wordpress#post-and-page-insights

Plausible Analytics WP - Post and Page Analytics preview
ThomasTr commented 1 year ago

Hi @oliveratgithubm looks nice 👍 For me the aproach in the posts list fits better, so i don't have to navigate in each post. I wrote the following in my funtions.php last night as a quick hack with hardcoded uri's:

add_filter( 'post_row_actions', 'add_analytics_link', 10, 2 );

function add_analytics_link( $actions, $post )
{
    $actions['analytics'] = '<a href="https://__MY_ANALYTICS__URI/__MY_SITE__?period=30d&page=' . urlencode('/'.$post->post_name) . '" target="_blank">Analytics</a>';

    return $actions;
}

Which results in the following link below each posting when you hover over it:

Screenshot

Of course, you could change this to an overlay that loads the data via Javascript so that you don't have to leave the page. But for a first hack without spending much time, that's enough for me for now.

Dan0sz commented 1 year ago

This is really cool, guys! Thanks for the work!

@metmarkosaric should we put this on the roadmap?

metmarkosaric commented 1 year ago

yeah i think we could add this in the future. the "Disable menu in toolbar" section of the plugin settings could be changed to include this as an option too. should not be on by default i think as it might make things too noisy for some people