Route data

Once gtag.js has been installed, you can configure it to send (or route) data to groups of accounts or products. Complete tracking solutions for AdWords, Analytics, and DoubleClick can be configured all from within the same tag. This guide explains how to use gtag.js to send data to specific products, accounts, and configurations using the send_to parameter and groups.

Default routing

Each global snippet contains a config command to handle routing. For example, the Google Analytics global snippet configures gtag.js to send data to a specified Analytics account:

gtag('config', 'GA-TRACKING_ID-1');

You can override the routing that's specified in the global snippet (or any earlier routing instructions on the page) by adding the send_to parameter to event commands. For example, the following sign_in event is sent only to Google Analytics property 'GA-TRACKING_ID-2', regardless of which targets were configured previously on the page.

gtag('event', 'sign_in', { 'send_to': 'GA-TRACKING_ID-2' });


Sometimes you may need to send certain information to a set of accounts or products, and send other pieces of information to another set of accounts or products. For example, you may want to send information about specific marketing campaigns to your ad agency, while retaining more complete data for your organization. This functionality can be organized using groups.

You can create a group of targets (e.g. products, accounts, and properties) and then route events to that group. In the following example, two Google Analytics properties are added to a group named group1. Then, a sign_in event is routed to the two properties in that group.

gtag('config', 'GA-TRACKING_ID-1', { 'groups': 'group1' });
gtag('config', 'GA-TRACKING_ID-2', { 'groups': 'group1' });

// Routes to 'GA-TRACKING_ID-1' and 'GA-TRACKING_ID-2'
gtag('event', 'sign_in', { 'send_to': 'group1' });

Default group

If a send_to parameter is not set, events are routed to the default target group. The default group includes all products and accounts from config commands on the page that have executed prior to the event. Even if the groups parameter is not specified in a config command, the target is assigned to the default group.

// The following two lines are equivalent:
gtag('config', 'GA-TRACKING_ID-1');
gtag('config', 'GA-TRACKING_ID-1', { 'groups': 'default' });

The next example illustrates that events are sent to the default group, regardless of whether {'send_to : 'default'} is specified.

// Configure a target
gtag('config', 'GA-TRACKING_ID-1');

// Since send_to is not specified, this routes to the 'default' group which
// includes 'GA-TRACKING_ID-1', as defined in config, above.
gtag('event', 'sign_in');

// By default, routes to the 'default' groups which includes
// 'GA-TRACKING_ID-1', as defined in config, above.
gtag('event', 'generate_lead', { 'send_to': 'default' });

Route to custom groups

Using groups, you can identify certain pieces of data that should be routed to a specific set of tracking IDs. The following code sample illustrates how to route sign_in event data to a custom group called agency.

// Configure a target
gtag('config', 'GA-TRACKING_ID-1');
gtag('config', 'GA-TRACKING_ID-3', { 'groups': 'agency' });
gtag('config', 'GA-TRACKING_ID-9', { 'groups': 'agency' });

// Routes only to 'GA-TRACKING_ID-3' and 'GA-TRACKING_ID-9' since they
// are both in the 'agency' group
gtag('event', 'sign_in', { 'send_to': 'agency' });

Example: Configure AdWords, Analytics, and DoubleClick together

You can create complete tracking configurations for AdWords, Analytics, and DoubleClick all from within the same global site tag. The following example demonstrates what a combined tag might look like. This example demonstrates the following:

  • Sends pageview data to Google Analytics.
  • Tracks AdWords and DoubleClick Floodlight conversions.
  • Sends information about an item added to a shopping cart to Analytics and AdWords.
<script async src="">
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  // Global configs
  gtag('config', 'GA-TRACKING_ID-1');
  gtag('config', 'AW-CONVERSION_ID');
  gtag('config', 'DC-FLOODLIGHT_ID');

  // Track AdWords conversions
  gtag('event', 'conversion', {
      'send_to': 'AW-CONVERSION_ID/AbC-D_efG-h12_34-567',
      'value': 1.0,
      'currency': 'USD'

  // Track Floodlight conversions
  gtag('event', 'conversion', {
    'allow_custom_scripts': true,
    'send_to': 'DC-FLOODLIGHT_ID/actions/locat304+standard'

  // route ecommerce add_to_cart event to AdWords and Analytics
  gtag('event', 'add_to_cart', {
    'send_to': [
    'items': [
      'id': 'U1234',
      'ecomm_prodid': 'U1234',
      'name': 'Argyle Funky Winklepickers',
      'list': 'Search Results',
      'category': 'Footwear',
      'quantity': 1,
      'ecomm_totalvalue': 123.45,
      'price': 123.45