Set up event parameters

This guide shows you how to set up parameters for recommended events and custom events on your website so you can collect more information from your events. For information about how to add item-scoped parameters, see Measure ecommerce.

Audience

You want to collect more information about your users' activity through the events you've already set up.

You use either the Google tag (gtag.js) or Google Tag Manager on your website. If you want to set up event parameters for a mobile app, see Log events.


Before you begin

This guide assumes that you've done the following:

It also assumes that you have the following:

  • Access to your website source code
  • The Editor (or above) role to the Google Analytics account

You should also read Set up events before reading this guide.

Understand event parameters

Parameters provide additional information about the ways users interact with your website. For example, when someone views a product you sell, you can include parameters that describe the product they viewed, such as the name, category, and price.

The automatically collected and enhanced measurement events include parameters by default. Google also provides a set of required and optional parameters to include with each recommended event. Additionally, you can add more event parameters when you need them.

Set up event parameters

Events have the following structure, where <event_parameters> are your event parameters, written as key-value pairs:

gtag('event', '<event_name>', {
  <event_parameters>
});

Consider the following example:

gtag('event', 'screen_view', {
  'app_name': 'myAppName',
  'screen_name': 'Home'
});

In this example:

  • app_name and screen_name are event parameter names
  • myAppName and Home are event parameter values

Set up parameters for every event

The examples in the previous section use the event command in a gtag() function to send parameters for one event. You can also update the config command in the Google tag snippet (in your <head> HTML tag) to send parameters with every event on the page.

The following sets the page title and then sends the parameter with every event on the page:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-XXXXXXXXXX', {
  'page_title': 'Travel Destinations',
  'currency': 'USD'
});
</script>

If you add more than one tag ID to your page, add a set command instead of updating the config command so all the IDs inherit the parameters you set. Place the set command above the config command.

gtag('set', {
  'page_title': 'Travel Destinations',
  'currency': 'USD'
});
// Place your config commands after the set command like follows
gtag('config', 'G-XXXXXXXXXX-1');
gtag('config', 'G-XXXXXXXXXX-2');
gtag('config', 'G-XXXXXXXXXX-3');

See your events in Analytics

You can see your events and their parameters using the Realtime and DebugView reports. Note that the DebugView report requires some additional configuration before you can use the report. These two reports show you the events users trigger on your website as the events are triggered.

Some parameters automatically populate prebuilt dimensions and metrics in Google Analytics. For example, the parameters on the automatically collected and enhanced measurement events, as well as the required and optional parameters you send with the recommended events, populate pre-built dimensions and metrics.

Other parameters require you to create custom dimensions and metrics to see the parameter values in Google Analytics. Whenever you create a custom parameter, you need to create a corresponding custom dimension or metric so you can see that data.

Next steps

Create custom dimensions and metrics for your custom event parameters.