2.2K members online now
2.2K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
Guide Me

Problem Getting UserID into GA

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭



I have a website with user sign-in and I'm trying to send the User ID data into GA but not being successful.


I have set up GTM as shown

Screen Shot 2016-07-07 at 05.48.56.png



Screen Shot 2016-07-07 at 05.49.14.png


And user ID tracking is enabled in GA


Screen Shot 2016-07-07 at 05.49.36.png

Our user ID is coming through in the datalayer as seen below


Screen Shot 2016-07-07 at 05.51.15.png


But nothing appear to be being sent through to GA (and the reports in the new view I have set up are empty. ). Any ideas/suggestions?


Screen Shot 2016-07-07 at 05.51.34.png

 Could it be a timing issue if the userId variable is not defined at the time that the tag fires?





Re: Problem Getting UserID into GA

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆
Hi Jonathan,

When you're implementing userId with dataLayer you need to make sure that dataLayer is defined before any UA tag fires. Usually it's done by hardcoding JavaScript assigning UserID before GTM snippet. Otherwise when your UA tag fires it has no data for "&uid" variable in dataLayer to send to UA so that variable resolves to "undefined" as it seem to be the case in your particular situation.

Here is a great guide from Simo Ahava about using dataLayer in GTM particularly for userID functionality:

Particulary this code from above article you may find useful:

window.dataLayer = window.dataLayer || [];
'userId' : 'abf5-3245-ffd1-23ed'
<!-- GTM Container Snippet Code Here -->

Also if above is not the case a few follow-up questions/suggestions:

1. Did you enable custom dimension in GA that is specified in UA firing tag? Is it hit level? Is it at the same index number as you have it in tag?

2. Do you check your data in User-ID view or regular view? Is User ID view enabled? Does your custom dimension show any data when applied to any standard report in your regular view?

3. Google strictly recommends that field containg userID should be named "&uid" in Fields to set part of UA Tags in GTM. Did you try doing that? Source: