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

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

Tracking logged in users with Google Tag Manager

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I have a similar situation to Bryan S in another thread, except I don't have the authentication status available on the page, just the userId, if the user is logged in. I have installed a Joomla plugin that passes the userId to the dataLayer. When I am in preview mode and login, the left column of the console shows the first event is user_loggedin. If I click on this event and look at Variables, I can see the value of the logged in user is in the variable userId.


I want to set a variable to show either authenticated or unAuthenticated BEFORE the pageview tag fires, but I am not having any luck.


Following the instructions in this post, I did the following:

1) I created a trigger called "Authenticated User", type = custom event, event name = user_loggedin, fires on all custom events.

2) I created a DataLayer variable called "isAuthenticated".

3) Then I created a Tag called "PUSH - User Authentication", type = Cutstom HTML, and input this code:
'isAuthenticated': 'authenticated',


All this works except the "Page View" event is complete before the "Message" from the "PUSH - User Authentication" tag. So the value for isAuthenticated is not updated before the Pageview is sent to UA, so the value of my custom dimension is incorrect - undefined rather than "authenticated".


I have tried giving "PUSH - User Authentication" a higher Tag firing priority (priority of 9) than my "GA - Standard Pageview" tag (priority of 1). This didn't work.


I tried Tag sequencing with a Setup and Cleanup tag, but I still cannot get the isAuthenticated status set correctly BEFORE the Pageview.


Any suggestions?

Tracking logged in users with Google Tag Manager

Follower ✭ ✭ ✭
# 2
Follower ✭ ✭ ✭



The priority configuration is effective only when using the same trigger. In this case, I think that you are probably sending "PUSH - User Authentication" and "GA - Standard Pageview" with different triggers.


If the timing of the user_loggedin event is between Pageview and DOM Ready, I think that if you set the pageview trigger to DOM Ready. 


How about that?