logo
To improve the performance of your ML model and attribution, it’s necessary to implement the tracking of several event parameters and user properties in Google Analytics.

General Steps

  1. Pass the Parameter to dataLayer: For each event or user property, pass the relevant parameter (e.g., user_id, ip_address, ever_paid, is_first_purchase etc.) to your dataLayer.
  1. Send the parameter to Google Analytics via Google Tag Manager (GTM) or gtag.js:
      • For GA4 via Tag Manager:
        • Tracking user properties:
            1. If you don’t already use a Google Tag: Event Settings variable, create one.
              1. Image without caption
            1. Under the User Properties section of your Google Tag, add a new row with the Parameter and the corresponding Value (the Data Layer variable you created).
            1. Select the created Event Settings Variable in each GA4 configuration and event tag.
              1. Image without caption
        • Tracking event parameters:
            1. Open your GA4 event tag that tracks conversions.
            1. In the Event Parameter section, add a new row with the Parameter and the corresponding Value (the Data Layer variable you created).
              1. Image without caption
      • For GA4 using gtag.js: Add the parameter to the appropriate command in your measurement code:
        • Tracking user properties:
          • javascript
            gtag('config', '<TAG_ID>', { '<parameter_name>': '<parameter_value>' });
        • Tracking event parameters:
          • javascript
            gtag('event', '<event_name>', { '<parameter_name>': '<parameter_value>' });

Parameters to Implement

  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' });
  1. User property - IP Address (ip_address)
    1. Collect the user's IP address. Please note that collecting a user's IP address should only be done after obtaining their explicit consent.
      • Example for gtag.js:
      javascript
      gtag('config', 'STREAM_ID', { 'user_properties': { 'ip_address': 'IP_ADDRESS' } });
  1. User property - Ever Paid (ever_paid)
    1. Track whether a user has ever converted with a true or false flag.
      This parameter is necessary freemium subscription based businesses where users can login to the platform on the same website where they can convert, it’s necessary to be able to differentiate all actions of converted customers.
      • Example for gtag.js:
      javascript
      gtag('config', 'STREAM_ID', { 'user_properties': { 'ever_paid': '<true or false>' } });
  1. Event parameter - First-Time Purchase (is_first_purchase)
    1. Indicate whether the event is a first-time or repeat conversion.
      • Example for gtag.js:
      javascript
      gtag('event', '<event_name>', { 'is_first_purchase': '<true or false>' });

Creating user scoped custom dimensions

It’s recommended to create user level custom dimensions inside your GA4 admin panel for the user properties ever_paid and ip_address.
Follow these steps in your GA4 admin panel:
  1. Go your GA4 property’s Admin settings.
  1. In the Data display section, select Custom definitions.
  1. Click on Create custom dimension.
  1. Set the Scope to User.
  1. In the User property field, enter the name of the user property exactly as it’s sent to GA4 (e.g., ever_paid, ip_address).
  1. Click Save.
Image without caption