Historical custom dimension value is changed

Hi, I have some problems with historical custom dimension values.
I have setup two custom dimensions

  1. “source” - this is static value
  2. “userId” - this is changed when logged in or logged out

There are situations where Im logged as User1, sending some custom events with proper custom dimension values (debugger etc. showing proper values), then loggin on User2 with different userId ofcourse, sending different custom events with proper custom dimension values. When I check Tracker debugger again, my historical events from User1 is changed, and its only 1 event, not all of them.

Here are some images presenting scenario:

On first image everything is correct, Page view custom event with Page title “User list” have proper userId (4532…) and all other events aswell.
On second image the event with Page title “User list” changed userId custom dimension value to value which User2 has even tho this event is few minutes old. Only this event, no other events changed this value. Seems like value is always changing only for last custom page view event between changing users.
Third image is just showing other User2 events.

Here I have also checked network for all sent events in this scenario:

Payload for all requests are correct, meaning they have proper userId custom dimension value.
When B2 request is triggered custom dimension userId is changed to another one, but event from request A7 is changed on PiwikPro platform side.

So I checked raw data from Tracker debugger too:

and raw data was always correct.

Everything happend on same browser and same tab.
Custom dimensions are taken from data layer.
Tried to change custom dimension names in case “userId” variable name can cause conflict problems but same issue occur.
Only last custom page view event has this problem.

Are you using a session custom dimension or a event custom dimension? It may be that you’ve created an event custom dimension?

User ID usually makes more sense as a session dimension although if people are for some reason logging in and out and changing accounts often an event scoped custom dimension may make more sense.

I’d also probably set the user ID using the API instead of a custom dimension. Then your user reports/returning users will work more effectively cross-device.

Can you tell us what you are trying to achieve? I find it a bit hard to follow your explanation

Its actually semi-user id, so its not real user id. I just want to have information on every single event with semi user id.

When user is logged out value should be “N/A”.
When user is logged in value should be “<semi_user_id>” (every user have its own semi user id).
Having possibility to change user accounts in the same session time, on same device, browser and tab.

I think it doesnt really matter if its userID, semi-userID or something else, seems like historical custom dimension value is changing. Because what if I want any other custom dimension not related to user id at all, seems like it will have the same problem.

Perhaps this API setUserID will work for now for my current requirements, but will have to check it. Still seems like a bug to me, because what if I will need some other custom dimension value which changes multiple times in same session time (unless custom dimensions shouldnt be used like that). Also its weird that only 1 event is historically changed, not all of events in the same session.

I presume it’s a session dimension then?

Then it won’t work when a user changes their account. All events will be attributed to the latest user_id set.

I’d imagine this may be an issue with the tracker debugger. I’d wait until tomorrow and see if it’s a problem in a report or just a UI issue with the tracker debugger.

@alexanderf what do you mean by “session dimension”?
I can’t recall that I can set custom dimesion to session or not. Where can I find it?
Im just using Analytics -> Settings -> Custom dimensions with this approach:

I tried to do setUserId and resetUserId while adding custom dimensions under userIdX variable, and Tracker debugger still has the same issue.

Unfortunatelly without setUserId and resetUserId reports were also showing invalid data (I can clearly see when its invalid, because Im using two users with different roles, where they cannot access the same places), with setUserId and resetUserId I will know if data on reports are valid or not on monday.

I don’t really understand the connection to session dimensions value, because it is only the last page view event, never happend to any other type of events, or any events with type page view but not last one before changing dimension value. If it happend to all events in the same session they I would agree with it.

When you create a custom dimension you can choose between an event custom dimension or a session custom dimension. See the picture here:

Session custom dimensions are set for the entire session. For instance the “source/medium” is a session dimension because you can filter on sessions with "source/“medium” = “google/cpc” and view every event those users have made - even on subsequent pageviews. Very handy because you can then “retroactively” add the value to the entire session. For instance, if you set the session dimension “customer_id” when a user logs in the events before they logged in will also have the session dimension set.

On the other hand event custom dimensions are set on just exactly the event you have chosen to add the custom dimension to. For a parallell the “Event Category” is an event dimension, as it’s applied to just one specific event (the custom event you sent in). So, let’s say you want to track a user_id with an event custom dimension you’ll need to add the custom dimension “user_id” to every single event that Piwik sends. That means that you’ll need the user id available at all times - even on subsequent page loads. And then the specifics of your MTM/GTM implementation start mattering a lot and not Piwik itself. It’s harder setting it up with an event scoped custom dimension because you’ll need to be vigilant that the user_id is always accessible.

I’d go for a session scoped dimension but you’ll have to give up on tracking users who use multiple accounts in the same session. I usually make that tradeoff for simplicity in implementation as on most websites it’s an edge case.

Sorry in advance if you already know this :slightly_smiling_face:

And yeah, check it on monday! Could just be the tracker debugger acting strangely/not updating retroactively if it’s a session dimension. Let me know :stuck_out_tongue:

@alexanderf btw thank you for answering.
RIght, I forgot that there are 2 buttons for adding dimensions. I checked mine dimensions and they were always event dimensions:

So I guess they were correct for my requirement.
I got report result, and looks like its not just Tracked debugger visual bug.

I have created URLs where you can see specific role after “…/user/” in URL path to easily see if IDs were working properly (ofcource only X role can acces “…/user/X/…” URL).
As we can see on image last row on report table has incorrect “User ID X” dimension value.
“User ID” which is build-in variable, seems to be consistently replaced by most recent user id value I set for all events in single session. “User ID X” which is custom event dimension is only replaced in last page view event between changing user id.

Looks like PiwikPro bug to me. The last thing I can try I guess, is to set this custom event dimension everytime I send the event. As I understand it, it should work properly when i change this value when I change user, not everytime I send any event.

Yeah, working as intended with the user-id. It’s being set to the final value it sees and retroactively applying it to earlier events.

If it’s a hard requirement that logging in and out works gracefully you can use an event dimension and send it with every hit. Any issues you have is likely due to your implementation in MTM/GTM and not with Piwik itself.

Figure out how to have the user-id accessible on all pageviews and you should figure it out. Maybe set a cookie with the user-id when a user logs in/out and then always read from that value. Know that this has some GDPR/Privacy implications and cookie lifetimes are kind of a bitch nowadays so if you can solve this with cookies set by your server and not javascript that’ll be even more reliable :slight_smile:

No worries, best of luck!

Yes built-in user id is working as intended no problem with that.

Im using custom event dimension and its not working, even when I send it with every hit (checked it today).
I cant see why its my MTM/GTM implementation issue. If you could please explain why was it changing only 1 page view event and not all events in session or all page view events (just how built-in user id or session dimension is doing it).

Rather not use cookies at all. Have to comply with GDPR etc.

Seems like I found a “fix” which works for me.

To make everything work for me I just removed Custom ping events which are presented on the first post. I dont know why they were breaking this 1 event. Only thing I noticed, they were very close to each other (timeline wise), but I still think it should not cause historical event value to change. Not even setUserId and resetUserId were needed.

Works for now, but Im kind of concerned, that if I will have events very close to each other some value might be changed historically - I dont know if its ping issue or being very close or what exactly (looks like some bug to me).