Custom Variable contains corrupted data


#1

I added these lines to the tracking script
var userName = ‘<%= Request.ServerVariables(“AUTH_USER”) %>’;
paq.push([‘setCustomVariable’,1,‘LoginName’,userName,scope = ‘visit’])

The source on the web page shows this

var _paq = _paq || [];
var userName = ‘FOLEY\XXX15’; I REPLACED NUMBERS WITH X’S for security reasons
_paq.push([‘setCustomVariable’,1,‘LoginName’,userName,scope = ‘visit’]);
_paq.push([‘trackPageView’]);
_paq.push([‘enableLinkTracking’]);
(function() {
var u=((“https:” == document.location.protocol) ? “https” : “http”) + “://piwik/piwik/”;
_paq.push([‘setTrackerUrl’, u+‘piwik.php’]);
_paq.push([‘setSiteId’, 3]);
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);
})();

In the visitor log LoginName is FOLEY15 instead of FOLEY\XXX15

Wed 9 Jul - 16:25:41
IP: 10.xx.xx.xx
Provider: Foleylaw

LoginName : FOLEY15

Is there a workaround for this? Is this a bug or did I do something wrong?


#2

I fixed my issue with a little research. The “” was causing the issue.
I replaced
var userName = ‘<%= Request.ServerVariables(“AUTH_USER”) %>’;
paq.push([‘setCustomVariable’,1,‘LoginName’,userName,scope = ‘visit’])

with this
var userName = ‘<%= Server.URLEncode(Request.ServerVariables(“AUTH_USER”)) %>’;
userName.replace(’%5c’,’-’);
paq.push([‘setCustomVariable’,1,‘LoginName’,userName,scope = ‘visit’])