Millhorn
Millhorn

Reputation: 3176

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...

enter image description here

I have no idea what I'm doing wrong, but the goal is to have something like this (pulled from a YT video)...

enter image description here

Upvotes: 0

Views: 498

Answers (1)

Ramanjineyulu k
Ramanjineyulu k

Reputation: 11

While creating the view you need to enable User_Id reports . Then only it will show user_id instead of client_id

Upvotes: 1

Related Questions