'How to display internal User ID instead of Client ID (ga cookie), in Google Analytics via GTM?
I have surfaced my system's user id to display as a JS variable. I created a Custom Dimension to pull that user id, and connect it to the client id provided by Google.
Here's the dimension's code...
function() {
try {
var tracker = ga.getAll()[0];
return tracker.get('clientId');
} catch(e) {
console.log("Error fetching ID");
return "Customer ID N/A";
}
}
The variable that displays our User ID is ECID. I've tried every which way I can think of, but the only thing that works is what's above. I don't want the cookie id. I want to be able to display our internal User ID.
Here's how the event fires...
I have no idea what I'm doing wrong, but the goal is to have something like this (pulled from a YT video)...
Solution 1:[1]
While creating the view you need to enable User_Id reports . Then only it will show user_id instead of client_id
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ramanjineyulu k |


