Set persistent values with gtag.js

To set values that will be sent with every event for a web page, update the config for your property with the values that you want to send.

For example, if all transactions on your site use the same currency, add the currency parameter to your config command, instead of specifying the currency in every single event.

gtag('config', 'GA_TRACKING_ID', {'currency': 'USD'});

You can set multiple parameters in a config command. For example, the following code sets the currency and country parameters at the same time.

gtag('config', 'GA_TRACKING_ID', {
  'currency': 'USD',
  'country': 'US'
});

If you configure multiple properties on a single page, it may be more efficient to use the set command.

gtag('set', {
  'currency': 'USD',
  'country': 'US'
});
gtag('config', 'GA_TRACKING_ID_1');
gtag('config', 'GA_TRACKING_ID_2');
gtag('config', 'GA_TRACKING_ID_3');

Assign array values

When assigning array values to a parameter, any existing array associated with the parameter is overwritten by the new array. For example, after the following code is executed:

gtag('config', 'GA_TRACKING_ID', {'names': ['Alice', 'Bob']});
gtag('config', 'GA_TRACKING_ID', {'names': ['Carol']});

the value of names is ['Carol'].