Quantcast
Channel: Piwik Forums - Support & Bugs
Viewing all articles
Browse latest Browse all 13117

Question about custom variable in Visitor Log.

$
0
0
Hi everyone,

I've installed Piwik and was trying out the custom variable features to track individual users of my website when I noticed something in the Visitor Log.

For example..when I logged in as "User1" , Visitor Log is able to capture this user's activities and set the custom variable as Visitor:User1, however when I switch to another username e.g "User2" using the same browser, somehow only the custom variable is replaced (in this case, User1 is replaced by User2). That is, there is no longer Visitor:User1, Visitor Log only shows Visitor:User2 and all the previous activities of User1 is now belong to User2.

So it looks like Visitor log will overwrite the custom variable whenever the IP(or when you are using the same browser? I'm not sure.) is the same, am I doing anything wrong? Or is this how it supposed to work?

Below is the code that I currently use to set my custom variable.

<script type="text/javascript"> 
  var _paq = _paq || [];
  _paq.push(['setCustomVariable',  
    1, 
    "Visitor", 
    "<?php
    if(isset($_SESSION['user'])){ // this is where i track my users
        echo  $_SESSION['user'];
    }
       ?>", 
    "visit" 
    ]);
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "XYXYXYXYXXY";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 1]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
    g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();

</script>

Could anyone clarify this? Thanks in advance for your help!

Viewing all articles
Browse latest Browse all 13117

Trending Articles