I use Joomla 3.7.2 for my website and would like to enable the Google Analytics User ID feature to discover how registered users interact with my site. I need to add the following line to my tracking code to send User-ID data to Google Analytics:
ga('set', 'userId', {{USER_ID}}); // Set the user ID using signed-in user_id.
However I think I need to change the USER_ID part of the code to something else in order to 'pull' the unique identifier from my site. What code should I use for a Joomla website to do this?
I've seen this code in another post:
$return = $model->register($data);
if($return == 'useractivate'){$userid = JFactory::getUser($username)->id;}
...but I'm not sure how this relates to the previous code or where to implement this on my website. Any help much appreciated!