Set persistent values with gtag.js

It is possible to set values that will be sent on every event for a web page. Update the config for your property and provide the value(s) you want to send with every event.

For example, if all transactions on your site use the same currency, you can specify the currency parameter once in your config rather than specifying the currency in every event:

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

It is also possible to set multiple parameters in your property's config. For example, the following sets the currency and country parameters at the same time:

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

If you have configured multiple properties on a single page, you are able to set values that will be sent on every event to every property using the set command:

gtag('set', {'country': 'US'})

Assign array values

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

gtag('config', 'GA_TRACKING_ID', {'names': ['Alex', 'Bobby']});
gtag('config', 'GA_TRACKING_ID', {'names': ['Charlie']});

the value of names is ['Charlie'].