Add user info from a custom table (manually entered)

I’d like to have the visitors on our company intranet be shown by name. I would use LDAP, but I don’t have access to that server. I’ve read some of the tracking API and custom variables, and I would pass along a userID string if I could get it, but since the website being tracked is a company blog in PHP from linux, there’s no authenticated login for the users. On top of that, modern browsers just won’t tell you who’s logged into the computer. If there were a way I could accomplish this given my constraints, I’m all ears…

I have medium-sized group of users who I know their IP addresses (DHCP on the network, but it rarely changes, and users all have dedicated workstations), so I’m pretty comfortable associating one user for an IP address. If I were to create a table in the piwik_ MySQL db, or even a plaintext file (YAML, .ini, anything) in a relevant folder, could I get piwik to look at the IP there and then assign the user_id every time that IP comes to visit?

I’ve tried assigning a user_id directly into the piwik_log_visit table for a user (which shows up in the visits log!) but if I wait past the 30 min window of a “new visit”, it doesn’t carry the user_id to the new visit, even if the same visitor_id. I didn’t think that would work, but I wanted to try.

Any ideas?

You don’t need acces to LDAP, as long as the browser does you can pass request values that the user has permission to read (their ldap data) and then pass these into the Piwik tracker (page tag). A simple script could obtain that data and pass values as new Custom Dimensions, such as team/office, if that data is actually stored in LDAP for your Users.

That said, I am not honestly sure why you want or need to collect Personally Identifiable Information (PII) by storing their full name. Demographic data for sure.

As each Visitor has a fixed, more or less, IP then their digital footprint would almost convert them to a User. Either that or you could actually set the IP as their UserID, which will give you a whole new report and Dimension to measure and/or segment by - User.

I certainly am not trying to tell you what to do :slight_smile: , although I do hope some of the above has been useful. If not, just ignore.

You don’t need acces to LDAP, as long as the browser does you can pass request values that the user has permission to read (their ldap data)

I agree this would be the way to go … except that browsers don’t let you have access to this type of information. If you’re using some sort of SSO like Kerberos for LDAP authentication, then you could talk with your web server and pass along some Kerberos tokens, which would then be authenticated against your LDAP/Kerberos server to give you the authenticated user name. But again, that requires access to the LDAP server to configure.

I’ve searched high and low, and there’s no javascript function such as “window.WindowsUser()” that gives you the logged in user in the browser. Older ActiveX plugins may have provided that functionality in the past, but they are either out of date, or discouraged against (rightly so).

A simple script could obtain that data and pass values as new Custom Dimensions

I’ve not been able to find anything like this for reasons I state above. Can you provide an minimal working example of such a script? I’m up for learning how to accomplish this.

What is the browser on your environment?if you are using IE then this can be achieved with vb script. Trying to do this with JavaScript and Firefox/chrome may be very tricky.

I can supply the vb script to do this if your are using IE.

I know this approach is not agnostic, but what is proposed is very much achievable as the browser uses the permissions of the user connected to LDAP.

Here is the code I said I would provide:

https://codeshare.io/24A4NE

Adding this before the Piwik fracker will enable you to pass the variables from VB to JS. If the script is able to connect to your LDAP of course. This may not work for you, does for me, but worth a try for free :slight_smile: