Search code examples
google-analyticsgoogle-datalayergtag.js

Is it possible to get back user_id programmatically when user browse a site?


I use gtag manager to push unique user_id from my site to ga. I wanna get it back like client_id when a user browse my site.

I definitely know that gtag does not allow to do that. also there is a dataLayer which can be queried like that google_tag_manager['<container-id>'].dataLayer.get('gtm.start') but I've not found a solution to get user_id back.

Is it possible somehow to get back this user_id or it works only in one way to enrich ga?


Solution

  • In the real time, it works one way only. It's your responsibility to save whatever you need appropriately.

    If it's shifted in time sufficiently (about 2 days shift), you theoretically could use the Data API or a BQ export to pull it by something like GA client id. But that's way too cumbersome. Much easier to preserve the user id in the normal way.