django-analytical icon indicating copy to clipboard operation
django-analytical copied to clipboard

GA not tracking logged in users, GTAG user_id seems to require a different syntax now

Open keyvanm opened this issue 3 years ago • 4 comments

Hi,

Thank you for this library! I've been using this for Google Analytics but having trouble loading user-id information there.

It seems like per Google documentation the code required to send user_id information looks like this:

gtag('config', 'G-XXXXXXXX', {'user_id': 'USER_ID'});
gtag('set', 'user_properties', { 'crm_id' : 'USER_ID' });

What the library renders is this:

gtag('set', {'user_id': 'USER_ID'});
gtag('config', 'G-XXXXXXXX');

Perhaps this is not sending the user id to GA properly? If you think this is the case, I can happily submit a PR to address this.

keyvanm avatar Oct 06 '21 03:10 keyvanm

Ok, so I just had to wait for the data to show up in GA. Is there any way to send custom variables to GA? The current implementation doesn't seem to support it. I can submit a PR to address this. I can update to the new syntax according to the latest docs too while at it.

keyvanm avatar Oct 07 '21 03:10 keyvanm

Sure, feel free to submit a PR to fix the implementation. Thank you!

bittner avatar Dec 23 '21 13:12 bittner

This problem seems to be related to #189. Can you confirm?

bittner avatar Jul 13 '22 15:07 bittner

I can confirm, that setting user_id works without the user_properties being set. At least according to my User-ID Coverage view, where it shows about 30% coverage.

Setting the additional variables might be a good idea. The provider can take it from the context.

PetrDlouhy avatar Jul 14 '22 10:07 PetrDlouhy