Sharepoint UserID Custom Variable Problem

Hi,

I am using PIWIK 2.1.0 to track users accessing a Sharepoint 2013 Foundation Server.

I am using http://googleanalytics365.codeplex.com/ to add the default webcode to every page which with the default tracking code work perfectly.

I want to collect the userID as a custom variable.

var userID = _spPageContextInfo.userId; gives the user ID and

_paq.push([“setCustomVariable”, 1, “UserID”, Userid, “visit”]); sends the variable

My problem is that often the tracking code fails when this custom variable code is added, not always but often and especially over slow connections.

Have people come across this before? Is there a recognized solution that either delays the code running or checks the variable is defined and if not runs the code without the custom variable to avoid the code stalling in order to get more accurate stats?

I have ‘Alerted’ the UserID variable and at the time the code is running it appears that sometimes the _spPageContextInfo.userId variable is not defined at that point.

Hello, for a all-included SharePoint Analytics solution, please learn more and contact us here: SharePoint Analytics - Analytics Platform - Piwik