Support » Plugin: Google Tag Manager for WordPress » Track user id in google analytics

  • Hi,

    I have activated the User ID view in Google Analytics and thru preview mode in GTM validated that the data layer is being populated with visitorid, etc. Then created a data layer variable in GTM – UserID – with the default value (not set). Then added that in the GA base pageview tag under “Fields to set” with value (not set).

    I cannot see the logged in user (my self) in the real time view in Google Analytics.

    Where have a done wrong or can it be that i am logged in to WordPress as admin.

    Normally i implement tags and they can be validated in preview mode, this is different.
    In general is there a way to validate that Google Analytics pic up a data layer?


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Thomas Geiger


    Hi Lars,

    with the default value (not set)

    Does this mean that you turned on the default value option and entered the string value “(not set)” or you left the default option unchecked in the GTM variable?


    I turned on the default value option in the Data Variable Configuration and entered the string value “(not set)”. I did it because this field cannot be empty in “Fields to set” in the Google Analytics pageview base tag (i realized).

    I Googled and read about in a blog post at analyticsmania:
    The last setting in the Data Layer Variable is Default Value. If you’re trying to access the value of a particular key in the Data Layer AND that key does not exist, “undefined” will be returned. Sometimes you might need to get a different default value, e.g. (not set), empty, or anything else. In that case, click the checkbox and set the default value.



    Plugin Author Thomas Geiger


    Hi Lars,

    You definitely should not add a default value for this variable.

    If no user is logged in, visitorId will be not present in the data layer, your GTM variable will be “undefined” and user id will not have any value in your GA hit. This is the expected behavior.

    Adding “not set” in the default value will break user id tracking.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Track user id in google analytics’ is closed to new replies.