WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know of a wordpress plugin or widget that uses Google Analytics to display the page views to the user of the page they are on?

The reason it need to integrate with google analytics is that I have page views from existing posts that I wish to be counted and the normal page view plugins don't show the historical views.

share|improve this question

closed as off-topic by Rarst Sep 13 '14 at 12:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

Not really sure what you are asking, if you have Google Analytics tracking activated you can drill down to page views/post views in the Analytics dashboard – Vince Pettit Aug 6 '12 at 7:52
I'd like the views to be shown in single page/post view, single.php – Grávuj Miklós Henrich Aug 6 '12 at 7:56
So you want to show how many views that page or post has had to all users? – Vince Pettit Aug 6 '12 at 8:35
Why specifically from GA... if you can achieve the same result then why not use one of those? – Vince Pettit Aug 6 '12 at 9:01
up vote 2 down vote accepted

Please check out the WordPress Post Analytics Plugin that we (WisdmLabs) have created.

http://wordpress.org/extend/plugins/wordpress-post-analytics/ This is available on the WordPress plugin repository as a free download.

We link your Google Analytics account to the plugin and pull data from the Analytics backend to showcase stats right inside any post. You have a choice of using shortcode or a template code snippet to embed the plugin on your website.

Feel free to let us know your feedback on the support forum or through our website.

share|improve this answer
thanks, this is the winner! :) – Grávuj Miklós Henrich Aug 7 '12 at 8:30
You might want to make this compatible with 3.6. – Bram Vanroy Oct 1 '13 at 16:17

You could do something like the following (merely an example, do not take literally):

$posts = get_posts( 'posts_per_page=-1' );
foreach ( $posts as $post ) {
    $url = url_encode( get_permalink( $post->ID ) );
    $get = wp_remote_get( "https://www.google.com/analytics/api?visits_for_url=$url" );
    if ( $data = wp_remote_retrieve_body( $get ) )
         update_post_meta( $post->ID, 'analytics_view_count', $data );

This process would then run as a daily/half-daily WP cron event.

I have zero experience with the API, so how you query data by URL, or as to what data types are returned, you'd need to read up on the documentation.

I would also assume that it has a query limit - you might need to throttle the process, or at least break it up into batches (perhaps the latter, especially if you have a large number of posts).

share|improve this answer
thank you for your answer! :) – Grávuj Miklós Henrich Aug 7 '12 at 8:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.