Reputation: 1620
I've been trying to send user_id to google analytics with no success so far. I followed the instructions on the console which is basically to set the 'user_id' as follows:
<script async src="https://www.googletagmanager.com/gtag/js?id=XXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'XXXXX', {'user_id': '{{ user.id }}'});
</script>
Most of the thread i've read was to configure in the old way: ga
Upvotes: 5
Views: 5109
Reputation: 5208
As per documentation , you should be setting it like so:
gtag('config', 'GA_TRACKING_ID', {
'user_id': 'USER_ID'
});
Upvotes: 6