logo
To improve the performance of your ML model and attribution, it’s necessary to implement the tracking of the user ID in Google Analytics.
For GA4 via Tag Manager:
  1. Pass the Parameter to dataLayer: On every page load after login, pass the relevant parameter user_id to your dataLayer.
  1. Create a Variable inside GTM that reads that value from the dataLayer.
    1. Image without caption
  1. Send the property to Google Analytics via Google Tag Manager (GTM) or gtag.js:
    1. Under the Configuration Parameter section of your GA4 Google Tag, add a new row with the user_id property and the corresponding Value (the Data Layer variable you created in step 2).
      1. Image without caption
    2. Select the created Event Settings Variable in each GA4 configuration and event tag.
      1. Image without caption

For GA4 using gtag.js

  1. Config parameter - User ID (user_id)
    1. Pass a unique user ID after login to track users across sessions on different devices.
      • Example for gtag.js:
      javascript
      gtag('config', 'STREAM_ID', { 'user_id': 'USER_ID' });