> ## Documentation Index
> Fetch the complete documentation index at: https://oneviewhub.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# GTM Server Setup

> Get started with OneView using Google Tag Manager Server-Side

<Frame>
  <img src="https://mintcdn.com/oneview/FipWTTFxnal05444/guides/sending-events/basic-setup/assets/setup-gtm.png?fit=max&auto=format&n=FipWTTFxnal05444&q=85&s=328636f4de411c1e2a8838c94e9ab6fc" alt="OneView setup" noZoom width="2142" height="1132" data-path="guides/sending-events/basic-setup/assets/setup-gtm.png" />
</Frame>

## Introduction

OneView uses Google Tag Manager Server-Side as the primary method for sending events. This server-side approach provides improved reliability, better data quality, and full compliance with privacy regulations.

<Steps>
  <Step title="Get your API key">
    1. Go to your OneView workspace
    2. Navigate to **Settings** > **API Key**
    3. Copy your API key

    <Warning>
      Keep your API key secure. You'll need it to configure the [GTM Server tag](/docs/guides/sending-events/backend/gtm-server). Never share it publicly or commit it to code repositories.
    </Warning>

    <Info>
      Your API key is used to authenticate requests from your Google Tag Manager Server Container. Learn more in the [API reference](/docs/guides/sending-events/api-reference).
    </Info>
  </Step>

  <Step title="Install OneView Tag template from Google Tag Manager® Gallery">
    <Card title="Server Tag" icon="link" href="https://tagmanager.google.com/gallery/#/owners/oneviewhub/templates/gtm-server-tag">
      Import the open source OneView Tag template in Server-side Tag Manager®.
    </Card>

    <Note>
      The template is open source and available on [GitHub](https://github.com/oneviewhub/gtm-server-tag). You can review the code, report issues, or contribute improvements.
    </Note>
  </Step>

  <Step title="Configure the tag template">
    After importing the template, create a new tag using the OneView Server Tag template and paste your API key into the **API Key** field. You can also configure the following:

    <AccordionGroup>
      <Accordion title="Need to prevent duplicate events? (Optional)" icon="refresh">
        You can provide an **idempotency key** to prevent duplicate events. OneView converts your string into a [UUID v5](https://en.wikipedia.org/wiki/Universally_unique_identifier), which becomes the `Event ID`. Events with the same `Event ID` are **deduplicated**: only the first is processed.

        <Tip>
          Use a string that is **guaranteed to be stable** across events you want to deduplicate (e.g., `transaction_id`, `event_name` + `user_id`).
        </Tip>

        You may optionally provide an idempotency key to **prevent duplicate events**. OneView internally uses a high-efficiency [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) format to store each `Event ID`.

        OneView will generate a **UUID v5** for you, based on your provided string. Multiple events with the same `Event ID` **are considered duplicates**, and only the **first occurrence** will be processed.
      </Accordion>

      <Accordion title="Need to add user information? (Optional)" icon="user">
        Configure additional user identifiers beyond what's automatically collected. The template supports:

        * 💻 **Client ID** - Anonymous browser/device identifier
        * 👤 **User ID** - Authenticated user identifier
        * 🏢 **Organization ID** - Organization or account identifier
        * 📧 **Email Address** - User's email (automatically hashed)
        * 📞 **Phone Number** - Phone number in E.164 format (automatically hashed)

        <Info>
          All identifiers from your Server Container's [Common Event Data](https://developers.google.com/tag-platform/tag-manager/server-side/common-event-data) are automatically included. Use this section to add identifiers not available in Common Event Data. Learn more about [user identifiers](/docs/guides/sending-events/user-identifiers).
        </Info>

        **How it works:**
        The template automatically collects all event data from your Server Container's Common Event Data, extracts user identifiers (client ID, user ID, email, phone) from event payloads, and captures event metadata including page location, referrer, and UTM parameters.

        **Privacy protection:**
        Email addresses are automatically hashed using SHA-256, phone numbers are hashed in both E.164 and numeric formats, and first and last names are automatically hashed. Plaintext PII is removed from requests (configurable).
      </Accordion>

      <Accordion title="Need to set consent manually? (Usually not needed)" icon="shield">
        Configure consent handling for the event. The template supports Google Consent Mode v1 (GCS) and v2 (GCD) and will automatically extract consent signals from event data.

        You can override consent settings for:

        * `analytics_storage` - Controls whether the event is processed by OneView
        * `ad_storage` - Controls whether Conversion API sends data to Media Partners
        * `ad_user_data` - Controls whether Enhanced Conversions include PII
        * `ad_personalization` - Controls personalized advertising flag in Conversion API

        <Note>
          If not explicitly set, consent values inherit from Google Consent Mode signals in the event data. If no consent signals are present, events are processed by default. Learn more about [how consent works](/docs/platform/compliance/consent) and [consent enforcement](/docs/platform/features/collection/consent-enforcement).
        </Note>

        **How it works:**
        The template automatically extracts consent signals from Google Consent Mode v2 (GCD) or v1 (GCS) and respects consent for analytics storage, ad storage, ad user data, and ad personalization. You can override these settings in the tag configuration if needed.
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Configure triggers">
    Set up triggers to fire the OneView tag for the events you want to track. Common triggers include:

    * **All Pages** - For page view tracking
    * **Custom Events** - For conversion events (purchases, sign-ups, etc.)
    * **GA4 Events** - When using GA4 as a source

    <Tip>
      You can use the same OneView tag with multiple triggers to track different event types.
    </Tip>
  </Step>

  <Step title="Test and publish">
    Test your configuration in preview mode, then publish your Server Container.

    <Check>
      The template automatically handles PII hashing, consent extraction, and request formatting. No additional configuration needed.
    </Check>
  </Step>
</Steps>

## Advanced Configuration

<CardGroup cols={2}>
  <Card title="Custom Domain" icon="globe" href="/docs/guides/sending-events/backend/custom-domain">
    Set up a reverse proxy to use your own domain for improved SEO and ITP compliance.
  </Card>

  <Card title="User Identifiers" icon="user" href="/docs/guides/sending-events/user-identifiers">
    Learn about all identifier types and how to configure them.
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Events not appearing in OneView?">
    1. Check that your API key is correct
    2. Verify the tag is firing in Preview Mode
    3. Enable debug mode in your Server Container to see request logs

    <Tip>
      The template logs all requests and responses to the console when debug mode is enabled.
    </Tip>
  </Accordion>

  <Accordion title="Server Container on a different domain?">
    If your Tag Manager® Server Container receives events from your website but is served from a different IP address (e.g., from a subdomain), you may need to configure a reverse proxy to ensure compliance with Apple Safari® Intelligent Tracking Prevention requirements.

    <Info>
      See the [Custom Domain guide](/docs/guides/sending-events/backend/custom-domain) for details on setting up a reverse proxy.
    </Info>
  </Accordion>

  <Accordion title="Need more help?">
    * See the [API reference](/docs/guides/sending-events/api-reference) for technical details
    * Check [troubleshooting guides](/docs/guides/troubleshooting/attribution-errors) for common issues
    * Review [How OneView Works](/docs/platform/how-it-works) to understand the architecture
  </Accordion>
</AccordionGroup>
