Use Google analytics to track an individual subscriber's behavior, page views, time on pages, etc.

Discussion in 'aMember Pro v.4' started by crogue, Dec 18, 2011.

  1. crogue

    crogue New Member

    Joined:
    Dec 17, 2011
    Messages:
    13
    This was something that I found REALLY useful in the v3 forum, so I thought I'd post it here with an update so that it works using the v4 code.

    If you have google analytics on your page, just put this code at the bottom of your footer (be sure that this comes AFTER the analytics tracking code script):

    HTML:
    <?php require_once '/home/crogue/public_html/member/library/Am/Lite.php';
    ?>
    <script type="text/javascript">
        try { var pageTracker = _gat._getTracker("UA-XXXXXXXX-X");
        pageTracker._trackPageview();
        pageTracker._setVar("<?php
    if (Am_Lite::getInstance()->isLoggedIn() )
        echo Am_Lite::getInstance()->getUsername();
    else
        echo '_NotLoggedIn';
    ?>");
    }
    catch(err) {}
    </script>
    
    Now when you go to google analytics, under Audience > Demographics > User Defined you'll be able to track each user's:
    VisitsPages/VisitAvg. Time on Site% New VisitsBounce Rate

    Pretty useful.
    skippybosco and s_teachings like this.
  2. s_teachings

    s_teachings Member

    Joined:
    Jul 24, 2008
    Messages:
    32
    Thanks Mr. Charming...

    I wish more experienced users (or programmers) would post useful and helpful code for us newbies to learn from. I will definitely be using your example, once we go live with v4.
  3. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Nice bit of code!

    Looks like you could also use that to seperate out free/paid members to figure out what your popular content is.

    Thanks for sharing.

    David
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Cool idea! I never heard about this before.
  5. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Wonder if this could be extended to IP address, allowing you to build a poor mans GetClicky, allowing you to track specific users (by IP) through to conversion (by username).

Share This Page