Set up event parameters
Events have the following structure, where 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 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.