0

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!

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Chris
  • 13
  • 5
  • 1
    Have you tried checking this page: https://forum.joomla.org/viewtopic.php?t=871090? The `{{USER_ID}}` should be a system generated, unique identifier provided when the user logs in. – nyuen Feb 22 '17 at 22:57
  • I have but I didn't understand what was suppose to replace the {{USER_ID}} part of the code! – Chris Feb 24 '17 at 08:57
  • Do you have any idea how I automatically grab the unique identifier? – Chris Feb 27 '17 at 14:17
  • I'm not sure but did you have a look in the link I posted? Also here https://docs.joomla.org/JFactory/getUser – nyuen Feb 27 '17 at 14:53
  • Yes I had a look, but it doesn't explain how the code works - I'm still at a loss as to how to implement user-ID tracking in Google analytics. I use sh404sef plugin – Chris May 18 '17 at 21:48
  • Possible duplicate of [How to return the user\_id from the Joomla-Framework on insert/update a (new) user](https://stackoverflow.com/questions/39558859/how-to-return-the-user-id-from-the-joomla-framework-on-insert-update-a-new-use) – Paul Sweatte Jun 10 '17 at 06:48
  • My query is slightly different - it's about how I can give Google Analytics a User ID. – Chris Jun 14 '17 at 17:04

0 Answers0