Track Unique Customer IDs: Custom Dimensions You Should Consider Implementing for More Precise Tracking via Google Analytics. Part 1

Google Analytics is the ultimate tool when it comes to tracking your visitors data. It takes time and skill to master all of its features, yet it requires a little tweaking to make the data play on your team. So, shall we? Let’s make the numbers a little more useful.

Actually, Google does track each visitor. It’s just that it won’t let you see the data. But, what if you’d like to merge that data with existing CRM info, or pass it to the sales team, provide them with more valuable insights? Well, you can.

Track Unique Customer ID

For this purpose, we can utilize the unique cookie Google Analytics provides every user with.

a. Have a Cookie

If you have an EditThisCookie addon or know your way around the ‘developers tools’, you can actually dig that cookie out. It’s called the ‘_ga’ cookie. You don’t have to go look for it. I did that job for you, so let’s move on.

We’ll need just that. Just the fact that it’s a ‘_ga’, and that it has a value that consists of several parts: GA1.2.1419139466.1503387420. Actually, we will need just the last 2 values.

b. Creating New Variables

To make use of the cookie, we’ll need to create a new variable, and let Tag Manager know that the cookie exists.

1. Go to Tag Manager, Variables, User-Defined Variables, and click [NEW] button.

2. Name the variable ‘ga cookie’, choose the type ‘1st Party Cookie’, and state the name as ‘_ga’.

c. Extract an Actual ID

Now we have to pass the value of the cookie into a new variable.

1. Create another variable ‘CID’ (short for customer ID).

2. The variable type is Custom JavaScript, and the actual script goes like this:

function() {
try {
var a = {{ga cookie}}.split(“.”)[2]+”.”+{{ga cookie}}.split(“.”)[3]
return a;
} catch(e) {
return “n/a”;

* I’ve included a little trick in the code to return a message ‘n/a’ if the value is not available. Otherwise, you will lose the data when the dimension will be included in the report.

3. Hit save.

d. Using Variable in a Tag (Event)

We’re about to create an event that will record the CID value, but this is optional as we will pass that dimension directly to the Analytics later.

Go to tags, hit the [NEW] button, and create an event:

  • Tag type: Universal Analytics
  • Track type: Event
  • Category: CID
  • Action: {{CID}}
  • Label: {{Page URL}}
  • Tracking ID: your google analytics ID

e. Passing the CID as a Dimension to the Analytics

  1. Now go to your main analytics tag > More Settings > Custom Dimensions.

2. We’re about to pass the CID variable to the analytics, so give it a index of 1, and a value — {{CID}}.

3. Go to your Google Analytics admin section (Property column) > Custom Definitions > Custom Dimensions.

4. Hit the [+NEW CUSTOM DIMENSION] button.

5. Name it ‘Lead’ (or whatever you like), the Scope is ‘Session’, tick the ‘active’ checkbox, and Save.

We’ll talk about tracking your best performing authors in Part 2 of the series. Stay tuned!