# Custom domain configuration

> This article is for developers who want to host server-side tagging in the
> same [first-party context](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#tracking_and_privacy) as their website. Same-origin serving is a best
> practice that lets you leverage the security and durability benefits of
> server-set cookies. The below instructions apply for setting up same-origin
> serving regardless of the Google tag deployed on your site (gtag.js or
> gtm.js).

When you first set up a tagging server, it is hosted on a domain provided by the
cloud provider. When you use the default endpoint, it delivers data to the
server container, but runs in a third-party context. To unlock the benefits of a
first-party context, such as more durable cookies, your tagging server and your
website have to run on the same domain.

The table below illustrates how you can host a tagging server when the parent
website is hosted on `www.example.com`:

|   | Same origin (best practice) | Subdomain | Default domain |
|---|---|---|---|
| Example URL | `https://www.example.com/metrics` | `https://metrics.example.com` | `https://metrics.run.app` |
| Server-set cookie access | Full access to security and durability benefits. | Full access to security and durability benefits. | **None.** Can only set Javascript cookies. |
| Setup complexity | Configure a CDN or load balancer to forward requests. May need to update DNS entries. | Update DNS entries. | Comes pre-configured. |

Pick your implementation option to get started.

<button value="subdomain">Subdomain</button> <button value="same-origin" default="">Same origin</button>

## Prerequisites

This guide assumes that you have:

- Set up a server container in [Tag Manager](https://developers.google.com/tag-platform/tag-manager/server-side/overview#create_a_tag_manager_server_container)
- [Set up a tagging server](https://developers.google.com/tag-platform/tag-manager/server-side/overview#set_up_a_tagging_server)

## Configure the custom domain

Pick an implementation option.