Mobile app version of vmapp.org
Login or Join
Courtney195

: GTAG User ID tracking not working I've turned on User ID tracking, and am using the following code: window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js',

@Courtney195

Posted in: #GoogleAnalytics

I've turned on User ID tracking, and am using the following code:

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '<UA-ID>');

//gtag('config', '<UA-ID>', {'user_id': '{% user_display request.user %}'});

// developers.google.com/analytics/devguides/collection/gtagjs/setting-values gtag('set', {'user_id': '{% user_display request.user %}'}); // Set the user ID using signed-in user_id.


I've confirmed that the user_id value is being properly set by the JS. Also, I am able to see tracking info, except that it is NOT attached to a user.

Wondering if anyone has set this up before and could help debug. Also, note that I am using GTAG not the older Analytics (which I believe is called UA - Universal Analytics).

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Courtney195

1 Comments

Sorted by latest first Latest Oldest Best

 

@Lee4591628

I figured this out, User ID has to be set before the pageview event is sent. Maybe just after the function gtag() declaration would help.

I switched over to the older analytics.js since it is much better supported. The same applies there as well.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme