Support » Plugin: Simple Membership » Member statistics

  • Resolved ctuxboy

    (@ctuxboy)


    Hello,

    Is there a way, analyze when members are logged in, counting member visits, and other member statistics?

    Christophe

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Hi, currently at present that feature is not added.

    Hi mbrsolution,

    Oh okay.

    I try then integrate Piwik analytics as solution.

    Regards,
    Christophe

    Plugin Support mbrsolution

    (@mbrsolution)

    That is good to know. Can you let me know if it works for you. I am curious to know.

    Thank you

    Hi,

    It works perfect with Piwik.
    Now it tracks the users login name, browser type,… and all the other Analytics stuff.

    Adding custom variables and a little php for ‘echo’ the username in the Piwik trackingcode do the job 🙂

    For more info, how setup this code:
    http://piwik.org/docs/custom-variables/

    Regards,
    Christophe

    Plugin Support mbrsolution

    (@mbrsolution)

    Thank you very much Christophe for sharing this information. I am sure others who want to carry out the same analytical tracking as you will find your solution invaluable.

    Regards

    Hi mbrsolution,

    No problem, with pleasure 😉

    Here the code that i used. Maybe it can help others…

    Customize and paste this code between the <head>-tags:

    
    ...
    <?php if(SwpmMemberUtils::is_member_logged_in()) { //if member is logged in show username, else show 'guest'
     global $current_user;
    	get_currentuserinfo();
    	$visitor_username = $current_user->user_login;
    	}
    	else
    	{
    	$visitor_username = 'GUEST';
    	}?>
    
    <!-- Piwik trackingcode -->
    <script type="text/javascript">
      ...
      _paq.push(["setCustomVariable", 1, "Members", "<?php echo $visitor_username; ?>", "visit"]);
      ...
    </script>
    <!-- End Piwik Code -->
    ...

    After that go to Piwik -> Visitors -> Custom variables or Piwik -> Visitors -> VisitorLogs in the Piwik dashboard and see all the usefull analytics stuff about your members.

    Very handy 🙂

    Christophe

    • This reply was modified 2 years, 10 months ago by ctuxboy.
    • This reply was modified 2 years, 10 months ago by ctuxboy.
    • This reply was modified 2 years, 10 months ago by ctuxboy.
    • This reply was modified 2 years, 10 months ago by ctuxboy.
    • This reply was modified 2 years, 10 months ago by ctuxboy.
    Plugin Support mbrsolution

    (@mbrsolution)

    Thank you very much 🙂

    That is a fantastic solution that will help others.

    Kind regards

    Hello,ctuxboy

    Your solution is exactly what I have been looking for.

    I would like to know more detail.

    I am using WP-Piwik.

    Is this possible to do it by using WP-Piwik?
    If so, please give me advice how to do it.

    Thank you

    Kmotoyama

    Hi @kmotoyama,

    I don’t use this plugin.
    I’m adding the code in themes header.php, between the <head>…</head> tags.
    After that (when your website has a visitor) look inside your Piwik Dashboard the variable (Members) automatic shows in your Piwik statistics.

    Hello, ctuxboy

    Thank you for replying.

    For my site, it was not worked by your original code. So I customized the code.
    The following is my customized code based on your code.

    <!-- Piwik trackingcode -->
    <?php
    $auth = SwpmAuth::get_instance();
    $user_data = (array) $auth->userData;
    $user_data['membership_level_alias'] = $auth->get('alias');
    extract($user_data, EXTR_SKIP);
    ?>
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['setCustomVariable','1','Members','<?php echo $user_name ?>', 'visit']);
      /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="https://example.jp/piwik/";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', '2']);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <!-- End Piwik Code -->

    I removed the plugin “WP-piwik”, and added the code in themes header.php, between the <head>…</head> tags.

    Now I can see the member statistics ( Piwik -> Visitors -> Custom variables / Piwik -> Visitors -> VisitorLogs).

    Your code is great hint for me.

    Thank you again!
    Kmotoyama

    Hi kmotoyama,

    Glad that it worked!
    Happy that i can help others with my code 🙂

    Regards,
    Christophe

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Member statistics’ is closed to new replies.