AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

1.5K members online now
1.5K 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

Please, help me to implement User-ID

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello everyone,

I'd like to include the User-ID tracking for Google Analytics, but all the examples I found online show a different code from the one we are using on our site.


Here is the line that Google is suggesting to add to track the User ID


ga('set', 'userId', {{USER_ID}}); // Set the user ID using signed-in user_id.

And here is the code we have currently on our pages (I have replaced our account ID with XXXX in the example below):


 var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'XXXXXXXX']);
  setTimeout("_gaq.push(['_trackEvent', '15_seconds', 'read'])",15000);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

	ga.src=('https:' == document.location.protocol ? 'https://' : 'http://') + '';

    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);


Do you have any idea where should I add the User ID code within the code above?




1 Expert replyverified_user

Re: Please, help me to implement User-ID

Rising Star
# 2
Rising Star
Hey Fabrizio,

That is a legacy version of the GA Tracking code. You need to upgrade your base analytics tracking code to Universal. if you go into the Admin>>Property Settings>> Tracking Code you can get the new code there.


Theo Bennett
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

Re: Please, help me to implement User-ID

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Oh! Thank you Theo, I didn't know that, I'll check out the new code then.

Thank you very much.