About GA4 Configuration Fields

2022/03/163 min read
bookmark this
Responsive image

Table of Contents

  1. client_id
  2. language
  3. page_location
  4. page_referrer
  5. page_title
  6. user_id
  7. user_properties

Introduction

GA4 has several configuration fields that control how data is collected and sent. This post documents each field, how to set it via gtag, and what the corresponding query string key and BigQuery column are.

Reference: https://developers.google.com/analytics/devguides/collection/ga4/reference/config

client_id

Stored as part of the first-party analytics cookie for 2 years, used to identify each user.

gtag('set', 'client_id', '123456');
gtag('event', 'test_gtag_set', { test_id: 'client_id'});

The collect?v=2 request's query string key will be cid. The BigQuery column is user_pseudo_id, and the cookie _ga value will be updated to GA.1.1.123456. After updating this value, subsequent requests will always set the same value since the cookie is updated.

language

By default, this uses the window object's navigator.language value.

gtag('set', 'language', 'en-ca');
gtag('event', 'test_gtag_set', { test_id: 'language'});

The collect?v=2 request's query string key will be ul. The BigQuery column device.language will be updated to en-ca. The navigator.language value won't be updated.

page_location

By default, this uses the window object's document.location value. It is not clear what condition would require updating this value.

gtag('set', 'page_location', '/test2');
gtag('event', 'test_gtag_set', { test_id: 'page_location'});

The collect?v=2 request's query string key will be dl. The BigQuery column event_params.page_location will be updated to /test2.

page_referrer

By default, this uses the window object's document.referrer value. If the user comes directly to the site, document.referrer should be empty and BigQuery will have no value.

gtag('set', 'page_referrer', 'https://technoapple.com');
gtag('event', 'test_gtag_set', { test_id: 'page_referrer'});

The collect?v=2 request's query string key will be dr. The BigQuery column event_params.page_referrer will be updated to https://technoapple.com. Because page_referrer has a value, event_params will add 2 more values: medium with the value referral and source with the value technoapple.com.

page_title

By default, this uses the window object's document.title value. It is not clear what condition would require updating this value.

gtag('set', 'page_title', 'my title');
gtag('event', 'test_gtag_set', { test_id: 'page_title'});

The collect?v=2 request's query string key will be dt. The BigQuery column event_params.page_title will be updated to my title.

user_id

The user's ID provided by the site.

gtag('set', 'user_id', '123');
gtag('event', 'test_gtag_set', { test_id: 'user_id'});

The collect?v=2 request's query string key will be uid. The BigQuery column user_id will be updated to 123. Once this value is set, subsequent gtag requests will always contain user_id as 123.

user_properties

Additional user preference information. You can set up to 25 additional user properties. The name maximum length is 24 characters and the value maximum length is 36 characters.

gtag('set', 'user_properties', {
  "data1": "1 data"
});
gtag('event', 'test_gtag_set', { test_id: 'user_properties'});

The collect?v=2 request's query string key will be something starting with up, e.g. up.data1. The BigQuery column is user_properties, and it should contain the object data1 with the value 1 data.

gtag('config', 'G-NFY53GVWDK', {
   'user_properties': {
      "data_10": "10 data"
  }
});
gtag('event', 'test_gtag_set', { test_id: 'user_properties'});

Conclusion

Understanding GA4 configuration fields is essential for properly tracking user behavior. Each field has a specific query string key in the collect?v=2 request and a corresponding BigQuery column. By using gtag('set', ...), you can customize how these fields are populated to suit your analytics needs.