Use aMember Username in JavaScript / GetClicky

Discussion in 'Customization & add-ons' started by mahodder, Sep 14, 2011.

  1. mahodder

    mahodder New Member

    Joined:
    Jun 23, 2009
    Messages:
    2
    Hi GetClicky.com can track visitors by username if I can send the logged in username via javascript.

    This is what they say to use:

    <script type="text/javascript">
    var clicky_custom_session = { username: "bob"};
    </script>

    How can I change bob to show what ever aMember login_name is currently logged in instead? I can get it via PHP but I don't know how to get the current username via JavaScript.
  2. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    So why not use php to get username and pass it to a javascript function?
  3. mahodder

    mahodder New Member

    Joined:
    Jun 23, 2009
    Messages:
    2
    A pain with the quotes and JS but this is what I came up with and it seems to work:

    <?php
    $amember = $_SESSION['_amember_user']['login'];
    print "<script>var clicky_custom_session = {username: ".stripslashes("'")."$amember".stripslashes("'")."};</script>";
    ?>

Share This Page