# Google Analytics Destination Config Reference


> Complete Rudder CLI reference for the Google Analytics (Universal Analytics) destination config keys, custom dimensions, server-side identify, and web device mode settings.



[Google Analytics](https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/) (Universal Analytics) is a web analytics destination. RudderStack sends events to Google Analytics' Measurement Protocol from its servers, or — for web sources — loads Google's `analytics.js` library in device mode.

In a Google Analytics destination spec:

- `type: ga`
- `definition_version: 1`

**Warning**

**RudderStack has deprecated the Google Analytics destination.**

To send events to Google Analytics 4, use the [Google Analytics 4](https://www.rudderstack.com/docs/rudder-cli/destination-types/google-analytics-4/) destination type, `ga4`, instead.

## Sample configuration

```yaml
version: rudder/v1
kind: destination
metadata:
  name: google-analytics-prod
spec:
  id: google-analytics-prod
  display_name: Google Analytics Production
  type: ga
  definition_version: 1
  enabled: true
  config:
    tracking_id: "{{ .GA_TRACKING_ID }}"
    send_user_id: true
    anonymize_ip: true
    enhanced_ecommerce: true

    dimensions:
      - from: plan
        to: dimension1
    metrics:
      - from: age
        to: metric1
    content_groupings:
      - from: section
        to: contentGroup1

    enable_server_side_identify: true
    server_side_identify:
      event_category: user_type
      event_action: User Enriched

    track_categorized_pages:
      web: true
    track_named_pages:
      web: true
    sample_rate:
      web: "100"
    site_speed_sample_rate:
      web: "1"

    event_filtering:
      blacklist:
        - Cart Viewed

    connection_mode:
      web: device
      cloud: cloud
    consent_management:
      web:
        - provider: oneTrust
          consents:
            - analytics
```

The above example loads `analytics.js` on web sources in `device` mode, where the `web`-keyed settings apply, and sends server-side events in `cloud` mode, where `enable_server_side_identify` lets `identify` calls through — see [Web device mode](#web-device-mode) and [Cloud mode](#cloud-mode).

## Config keys

`config` accepts only the keys listed below. The [shared config key rules](https://www.rudderstack.com/docs/rudder-cli/destination-types/#config-key-rules) cover unknown keys, defaults, and immutability.

**Info**

Google Analytics settings split by connection mode. The groups below say which mode each key affects. Rudder CLI accepts every key whatever the mode — a key for the other mode is stored and ignored.

In `cloud` mode Google Analytics accepts `identify`, `page`, `screen`, and `track`. In `device` mode, web sources send `page` and `track`; an `identify` call sets the user ID and mapped traits on the tracker for later hits, without sending a hit of its own.

### Connection

<div class="rs-ckeys">
<div class="rs-ckey" id="tracking_id">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">tracking_id</p>RequiredSecret</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Tracking ID of your Universal Analytics property, from <strong>Admin</strong> &gt; <strong>Tracking Info</strong> &gt; <strong>Tracking Code</strong> in Google Analytics.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>UA-</code>, <code>YT-</code>, or <code>MO-</code>, then digits, a hyphen, and up to 100 more digits — for example <code>UA-123456789-1</code>.</li>
<li>A Google Analytics 4 measurement ID (<code>G-…</code>) is rejected. GA4 properties take the <code>ga4</code> type.</li>
<li>A <code>{{ path || fallback }}</code> template is accepted in place of a literal.</li>
<li>A spec that omits this key fails validation with <code>'tracking_id' is required</code>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <p>Supply it as a <code>{{ .VAR }}</code> reference rather than a literal — see <a href="#secrets" >Secrets</a>.</p>
<p>See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#where-can-i-find-the-google-analytics-tracking-id" >Where can I find the Google Analytics tracking ID?</a>.</p>

</div>

</div>

</div>

### Tracking

These keys apply in both modes.

<div class="rs-ckeys">
<div class="rs-ckey" id="send_user_id">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">send_user_id</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Send the event&rsquo;s <code>userId</code> to Google Analytics as the user ID, for identified visitors. The dashboard calls it <strong>Send user-id to GA</strong>.
</p>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#identify" >Identify</a>.
</div>

</div>

<div class="rs-ckey" id="anonymize_ip">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">anonymize_ip</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Anonymize visitors&rsquo; IP addresses.
</p>

</div>

<div class="rs-ckey" id="include_search">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">include_search</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Include the query string in the page path sent with page views. The dashboard calls it <strong>Include the Querystring in Page Views</strong>.
</p>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#site-search" >Site search</a>.
</div>

</div>

<div class="rs-ckey" id="non_interaction">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">non_interaction</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Mark every event as a non-interaction hit, which doesn&rsquo;t count toward bounce rate. An event&rsquo;s own <code>properties.nonInteraction</code> overrides it.
</p>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#non-interaction-events" >Non-interaction events</a>.
</div>

</div>

<div class="rs-ckey" id="enhanced_ecommerce">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">enhanced_ecommerce</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Send ecommerce events through Google Analytics enhanced ecommerce. It must be turned on in Google Analytics too.
</p>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#enhanced-ecommerce" >Enhanced ecommerce</a>.
</div>

</div>

<div class="rs-ckey" id="enhanced_link_attribution">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">enhanced_link_attribution</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Turn on Google Analytics enhanced link attribution, for more detailed reports of the links visitors click. In <code>cloud</code> mode, the link ID comes from the event&rsquo;s <code>properties.linkid</code>.
</p>

</div>

<div class="rs-ckey" id="double_click">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">double_click</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Turn on Google&rsquo;s advertising features — remarketing, display ads, and demographic reports. The dashboard calls it <strong>Remarketing, Display Ads and Demographic Reports</strong>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>In web <code>device</code> mode, it loads Google&rsquo;s display features plugin.</li>
<li>In <code>cloud</code> mode, RudderStack instead marks each hit with the Measurement Protocol&rsquo;s <code>npa=1</code>, which disables ads personalization for that hit.</li>
</ul>

</div>

</div>

</div>

### Custom dimensions and content groupings

These keys apply in both modes. In each mapping, `from` and `to` are each at most 100 characters, or a `{{ path || fallback }}` template.

<div class="rs-ckeys">
<div class="rs-ckey" id="dimensions">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">dimensions</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>array of objects</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Maps event properties and traits to Google Analytics custom dimensions, which must exist in Google Analytics first.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>from</code> — event property or trait name.</li>
<li><code>to</code> — custom dimension, written <code>dimension&lt;index&gt;</code>, such as <code>dimension1</code>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">dimensions:
  - from: plan
    to: dimension1</code></pre></div>
</div><p>See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#custom-dimensions" >Custom dimensions</a>.</p>
</div>

</div>

<div class="rs-ckey" id="metrics">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">metrics</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>array of objects</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Maps numeric event properties and traits to custom metrics.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>from</code> — event property or trait name.</li>
<li><code>to</code> — custom metric, written <code>metric&lt;index&gt;</code>, such as <code>metric1</code>.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="content_groupings">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">content_groupings</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>array of objects</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Maps event properties and traits to content groupings, which group pages together in reports.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>from</code> — event property or trait name.</li>
<li><code>to</code> — content grouping, written <code>contentGroup&lt;index&gt;</code>, such as <code>contentGroup1</code>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#content-groupings" >Content groupings</a>.
</div>

</div>

<div class="rs-ckey" id="custom_mappings">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">custom_mappings</p>Internal</div>
  <p class="rs-ckey__field">
    Type:
    <code>array of objects</code>
  </p>
<p class="rs-ckey__field">
  Description:
  An older, combined form of <code>dimensions</code> and <code>metrics</code>. Cloud mode reads it only when neither <code>dimensions</code> nor <code>metrics</code> is set.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>from</code> — event property or trait name.</li>
<li><code>to</code> — an entry whose <code>to</code> starts with <code>cd</code> is a custom dimension, and one starting with <code>cm</code> is a custom metric.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  The dashboard keeps this field hidden. Rudder CLI accepts it so that a destination already carrying values keeps them. Leave it out of a new destination, and keep whatever <code>rudder-cli import</code> brings back.
</div>

</div>

</div>

### Cloud mode

These keys apply to events sent in `cloud` mode.

<div class="rs-ckeys">
<div class="rs-ckey" id="enable_server_side_identify">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">enable_server_side_identify</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Send <code>identify</code> calls to Google Analytics as events. When <code>false</code>, <code>identify</code> events sent in <code>cloud</code> mode fail with an error.
</p>

</div>

<div class="rs-ckey" id="server_side_identify">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">server_side_identify</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Event category and action for the events <code>identify</code> calls become.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Applies when <code>enable_server_side_identify</code> is <code>true</code>. Leave it unset otherwise.</li>
<li><code>event_category</code> — name of the <code>identify</code> trait whose value RudderStack sends as the event category. When the event has no such trait, the category is <code>All</code>.</li>
<li><code>event_action</code> — event action.</li>
<li>Set both or neither — Rudder CLI rejects one without the other. Omit the block to send the category <code>All</code> and the action <code>User Enriched</code>.</li>
<li>Each is at most 100 characters, or a <code>{{ path || fallback }}</code> template.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">server_side_identify:
  event_category: user_type
  event_action: User Enriched</code></pre></div>
</div><p><strong>Warning:</strong> Despite its name, and the dashboard's <strong>Server Side Identify Event Category</strong> label, <code>event_category</code> isn't the category itself. RudderStack sends the value of the trait it names — <code>event_category: user_type</code> sends each user's <code>user_type</code> trait.</p>
</div>

</div>

<div class="rs-ckey" id="disable_md5">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">disable_md5</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Don&rsquo;t fall back to an MD5 hash of <code>userId</code> for the client ID. The dashboard calls it <strong>Disable Md5 encryption from Client ID</strong>.
</p>

<div class="rs-ckey__extra">
  RudderStack takes the client ID from the <code>integrations</code> object, the <code>gaExternalId</code> external ID, <code>traits.cid</code>, or <code>anonymousId</code>, in that order. When none is set, it hashes <code>userId</code>, unless this is <code>true</code>. See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#how-rudderstack-takes-clientid" >How RudderStack takes <code>clientId</code></a>.
</div>

</div>

</div>

### User deletion

<div class="rs-ckeys">
<div class="rs-ckey" id="rudder_delete_account_id">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">rudder_delete_account_id</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  ID of the Google account RudderStack uses to delete users from Google Analytics, for example on a suppress-with-delete regulation. The dashboard calls it <strong>Data regulation account</strong>, and creates the account when you sign in with Google.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Applies whatever the connection mode — deletion runs from RudderStack&rsquo;s servers.</li>
<li>At most 100 characters, and must not contain line breaks.</li>
<li>A <code>{{ path || fallback }}</code> template is accepted in place of a literal.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  User deletion is available only on the Enterprise plan. See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#deleting-a-user" >Deleting a user</a>.
</div>

</div>

</div>

### Web device mode

These keys configure `analytics.js` in the browser, so they apply only when `connection_mode.web` is `device`. Each is an object keyed by `web`. Where the dashboard has a default, the SDK applies the same value when the key is unset.

<div class="rs-ckeys">
<div class="rs-ckey" id="track_categorized_pages">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">track_categorized_pages</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Also send a non-interaction event for each <code>page</code> call that has a category.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — boolean. Unset means <code>true</code>, the dashboard&rsquo;s default.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="track_named_pages">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">track_named_pages</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Also send a non-interaction event for each <code>page</code> call that has a name.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — boolean. Unset means <code>true</code>.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="use_rich_event_names">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">use_rich_event_names</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Name the events that <code>track_categorized_pages</code> and <code>track_named_pages</code> send <code>Viewed &lt;category&gt; Page</code> and <code>Viewed &lt;name&gt; Page</code> — for example <code>Viewed Signup Page</code>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — boolean.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="sample_rate">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">sample_rate</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Percentage of users to track.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — a percentage written as a string: <code>&quot;50&quot;</code>, not <code>50</code>. Rudder CLI checks only that it&rsquo;s at most 100 characters, or a template. Unset means <code>&quot;100&quot;</code>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">sample_rate:
  web: &#34;50&#34;</code></pre></div>
</div>
</div>

</div>

<div class="rs-ckey" id="site_speed_sample_rate">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">site_speed_sample_rate</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Percentage of users whose site speed data is collected.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — a percentage written as a string, on the same terms as <code>sample_rate</code>. Unset means <code>&quot;1&quot;</code>.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="domain">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">domain</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Domain the <code>_ga</code> cookie is set on. The dashboard calls it <strong>Cookie Domain Name</strong>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — string, at most 100 characters, or a template. Unset means <code>auto</code>.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="optimize">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">optimize</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Google Optimize container ID. With it set, the SDK loads the Optimize plugin.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — string, at most 100 characters, or a template. <strong>Secret</strong> — see <a href="#secrets" >Secrets</a>.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="set_all_mapped_props">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">set_all_mapped_props</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Set the mapped custom dimensions and metrics on the page, so every later event on that page carries them. When <code>false</code>, they&rsquo;re sent only with the event they came from. The dashboard calls it <strong>Set Custom Dimensions &amp; Metrics to the Page</strong>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — boolean. Unset means <code>true</code>.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="reset_custom_dimensions_on_page">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">reset_custom_dimensions_on_page</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Properties whose custom dimensions are cleared on each <code>page</code> call, before new values are set. Each name must also appear as a <code>from</code> in <code>dimensions</code>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — array of property names, each at most 100 characters or a template.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">reset_custom_dimensions_on_page:
  web:
    - plan</code></pre></div>
</div>
</div>

</div>

<div class="rs-ckey" id="named_tracker">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">named_tracker</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Send events through a tracker named <code>rudderGATracker</code> instead of the default tracker.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — boolean.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/#named-tracker" >Named tracker</a>.
</div>

</div>

<div class="rs-ckey" id="use_google_amp_client_id">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">use_google_amp_client_id</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Use the AMP client ID, so users are recognized across AMP and non-AMP pages.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>web</code> — boolean.</li>
</ul>

</div>

</div>

</div>

### Event filtering

**Warning:** [Client-side event filtering](https://www.rudderstack.com/docs/sources/event-streams/sdks/event-filtering/) is applied by the RudderStack SDK, so it affects only web sources connected in `device` mode. Rudder CLI accepts the block in any mode, but events sent in `cloud` mode reach Google Analytics unfiltered.

<div class="rs-ckeys">
<div class="rs-ckey" id="event_filtering">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">event_filtering</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Restricts which <code>track</code> events the SDK passes to Google Analytics, by event name.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Applies when <code>connection_mode.web</code> is <code>device</code>. Leave it unset otherwise.</li>
<li><code>whitelist</code> — array of event names to allow; every other <code>track</code> event is dropped.</li>
<li><code>blacklist</code> — array of event names to drop; every other <code>track</code> event is allowed.</li>
<li>The two are mutually exclusive, and Rudder CLI enforces it — setting both fails validation.</li>
<li>Each name is at most 100 characters, or a <code>{{ path || fallback }}</code> template.</li>
</ul>

</div>

</div>

</div>

### Per-source keys

Both keys are objects keyed by the local source type — the tokens listed under [Source types](#source-types). A key naming a source type this destination doesn't support fails validation.

<div class="rs-ckeys">
<div class="rs-ckey" id="connection_mode">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">connection_mode</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Maps each source type you connect to the mode its events reach Google Analytics in, using the modes in <a href="#source-types" >Source types</a>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>An entry is required for each source type you connect — see <a href="#connect-a-source" >Connect a source</a>.</li>
<li>A mode the source type doesn&rsquo;t support on this destination fails validation — for example <code>device</code> for <code>ios</code>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">connection_mode:
  web: device
  cloud: cloud</code></pre></div>
</div>
</div>

</div>

<div class="rs-ckey" id="consent_management">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">consent_management</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Consent provider configuration per source type. The entry shape, accepted providers, and the rules on <code>resolution_strategy</code> and <code>consents</code> are shared across all destination types — see <a href="https://www.rudderstack.com/docs/rudder-cli/destination-types/#consent-management" >Consent management</a>.
</p>

</div>

</div>

## Source types

Google Analytics accepts events from these source types in the mentioned connection modes:

| Source type | Connection mode |
| :-----| :-----|
| `android` | `cloud` |
| `android_kotlin` | `cloud` |
| `ios` | `cloud` |
| `ios_swift` | `cloud` |
| `web` | `cloud`, `device` |
| `unity` | `cloud` |
| `cloud` | `cloud` |
| `react_native` | `cloud` |
| `flutter` | `cloud` |
| `cordova` | `cloud` |
| `warehouse` | `cloud` |

Only `web` offers `device` mode, which loads `analytics.js` in the browser. See [RudderStack Connection Modes](https://www.rudderstack.com/docs/destinations/rudderstack-connection-modes/).

`warehouse` is the token a [Reverse ETL source](https://www.rudderstack.com/docs/sources/reverse-etl/) resolves to. Rudder CLI manages the destination’s `warehouse` entry — if the destination is connected to a Reverse ETL source, set `connection_mode.warehouse: cloud` in its spec, or `apply` removes it.

Rudder CLI can also declare the Reverse ETL connection itself, for the types listed under [Supported destinations](https://www.rudderstack.com/docs/rudder-cli/yaml-retl-connections/#supported-destinations) — see [Manage Reverse ETL Connections using Rudder CLI](https://www.rudderstack.com/docs/rudder-cli/retl-connections/).

**Info:** The dashboard additionally offers Google Analytics to AMP and Shopify sources. Rudder CLI doesn&#39;t manage those connections, so `amp` and `shopify` are invalid here.

## Connect a source

An event stream connection to this destination is checked against two rules at `validate` time.

**The source's type must be supported.** A source's type resolves to one of the tokens above before the check — a JavaScript source resolves to `web`, and webhook and server-side SDK sources resolve to `cloud`. Every type an event stream source can resolve to is supported here, so this check always passes.

**The destination config must carry a `connection_mode` entry for that source type.** This lives on the destination spec, not on the [connection spec](https://www.rudderstack.com/docs/rudder-cli/yaml-connections/). Without it:

```text
destination 'google-analytics-prod' config has no 'connection_mode' entry for source type 'web'
```

Google Analytics needs no additional config keys to connect a source of any type, in any mode.

## Secrets

`tracking_id` and `optimize.web` are the secret keys. Write each one you use as a `{{ .VAR }}` reference and supply the value at apply time:

```yaml
config:
  tracking_id: "{{ .GA_TRACKING_ID }}"
  optimize:
    web: "{{ .GA_OPTIMIZE_CONTAINER_ID }}"
```

```bash
export RUDDER_GA_TRACKING_ID="..."
export RUDDER_GA_OPTIMIZE_CONTAINER_ID="..."
rudder-cli apply

# or
rudder-cli apply --var-file secrets.vars.yaml
```

Note that:

- `rudder-cli import` writes only the secrets the API returns, as `{{ .VAR }}` references, and leaves the others out. Add any secret key it leaves out, then supply the variables before you apply — see [Secrets](https://www.rudderstack.com/docs/rudder-cli/destination-types/#secrets).
- In web `device` mode the tracking ID and the Optimize container ID are embedded in the page's JavaScript, so masking them protects your YAML, not the values themselves.
- `rudder_delete_account_id` only identifies the Google account connected in the dashboard. The account's credentials stay in RudderStack.

See [How to Use Variable Substitution in Rudder CLI](https://www.rudderstack.com/docs/rudder-cli/variable-substitution/).

## Changes by release

<p>No changes since this type became available.</p>

For changes across every destination type, see [Destination Type Changes by Release](https://www.rudderstack.com/docs/rudder-cli/destination-types/changes/).

## See more

- [Google Analytics Destination](https://www.rudderstack.com/docs/destinations/streaming-destinations/google-analytics-ga/) for event mappings, enhanced ecommerce, client ID handling, and user deletion
- [Google Analytics 4 Destination Config Reference](https://www.rudderstack.com/docs/rudder-cli/destination-types/google-analytics-4/) for the `ga4` type that replaces this one
- [Destination Type Reference for Rudder CLI](https://www.rudderstack.com/docs/rudder-cli/destination-types/) for the rules shared across destination types
- [Destination YAML Reference](https://www.rudderstack.com/docs/rudder-cli/yaml-destinations/) for the spec envelope

