Support » Plugin: Google Analytics Post Pageviews » Addition to source code

  • potnii

    (@potnii)


    In gapp_get_post_pageviews() function change $permalink from
    $permalink = '/' . (($ID != 1) ? basename(get_permalink($ID)) : null);
    to
    $permalink = '/' . (($ID != 1) ? basename(get_permalink($ID)) . '/' : null);
    and from
    $permalink = '/' . basename(get_permalink());
    to
    $permalink = '/' . basename(get_permalink()) . '/';

    When plugin makes call to google analytics api he uses ‘ga:pagePath’ filter. So if we have 2 articles where permalink of 1st is ‘website.com/permalink-part’ and 2nd is ‘website.com/permalink-part-two’, and we will ask google analytics about statistics on 1st article – we will get summary statistics of 1st and 2nd, because permalink of 2nd match to regular expression that takes information from google analytics on 1st.

    • This topic was modified 3 years ago by potnii.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author maximevalette

    (@maximevalette)

    Thanks for your submission.

    The issue with that is that it won’t take the possible pages into account, that’s why I didn’t add the trailing slash in the first place. What would you suggest?

    potnii

    (@potnii)

    What do you mean by

    it won’t take the possible pages into account

    ?

    I thought that every time when you view posts in admin panel it automatically download statistics by post permalink.
    Or there is issue in google analytics? (I just don’t have access to google analytics to test problem from both sides).

    Plugin Author maximevalette

    (@maximevalette)

    For example, posts with multiple pages have /page-1 /page-2 etc. so by removing the trailing slash it will take everything into account.

    potnii

    (@potnii)

    Ok. But what is the difference in statistics between post with multiple pages and single page? It seems like statistics of post with multiple pages is sum of statistics of it’s pages. For example statistics of such post will be ‘post/page-1’ + ‘post/page-2’ etc.
    And in admin panel we don’t see statistics of post’s pages.
    So I think there isn’t need in statistics of post pages. Or there is?

    Plugin Author maximevalette

    (@maximevalette)

    It seems like statistics of post with multiple pages is sum of statistics of it’s pages. For example statistics of such post will be ‘post/page-1’ + ‘post/page-2’ etc.

    Exactly, that’s why I can’t add the trailing slash, it wouldn’t work in every situation. Maybe the best way would be to add a setting.

    potnii

    (@potnii)

    I think there is no need to count post views this way. If I read first page of post and didn’t read second it doesn’t mean that I didn’t view post.
    For example youtube counts video views if you watch only 3 seconds of video.
    And also if to think that your way of post counting is right it means that we have to count post view on single page posts only if user scrolled to the bottom of page. I am sure it doesn’t happen this way.
    Is there any other controversial situation with post counting?
    And in the end you can add setting to make every user decide for himself what is the right way.

    Plugin Author maximevalette

    (@maximevalette)

    Added the setting in the new version 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Addition to source code’ is closed to new replies.