Server-side tracking is becoming an increasingly popular method for businesses to ensure more accurate data collection while improving privacy controls. With Google Tag Manager’s (GTM) server-side tracking, you can run your tags through a server before sending data to third-party platforms like Google Analytics. One key step in setting this up is configuring a custom domain, which makes your tracking more secure and avoids potential ad blockers that may interfere with your data collection.
This article will walk you through the basic steps to set up a custom domain for Google Tag Manager’s server-side tracking. We’ll keep things simple, so even if you’re new to server-side tracking, this guide will help you get up and running.
What Is Server-Side Tracking?
Before we jump into the technical setup, it’s helpful to understand what server-side tracking is. Traditionally, tracking codes (like those from Google Analytics or Facebook Pixel) are placed on your website’s frontend, where they collect data and send it directly to external platforms. This is known as client-side tracking.
With server-side tracking, the tracking codes run on your server instead of the user’s browser. The benefits of server-side tracking include:
-
More accurate data: Client-side tracking can be blocked by browser settings, ad blockers, or cookie restrictions, resulting in lost data. Server-side tracking bypasses these obstacles, ensuring more accurate data collection.
-
Better control over data: By routing the data through your server first, you have more control over what information is shared with third-party platforms, enhancing user privacy.
-
Improved page load speed: Running tags through your server can reduce the load on the user’s browser, leading to faster website performance.
Why Use a Custom Domain for Server-Side Tracking?
When setting up server-side tracking, you’ll need a domain for your tracking server. Using a custom domain (one that is branded with your website) has several advantages over a generic one:
-
Improved tracking accuracy: Some browsers and ad blockers target third-party tracking domains (such as Google’s). A custom domain is less likely to be blocked, ensuring that more of your data is captured.
-
Trust and transparency: A custom domain increases user trust because it’s associated with your brand, not an unfamiliar third-party service.
-
First-party data: Using your own domain for tracking helps maintain the data as first-party, which can be more reliable and less prone to privacy restrictions compared to third-party data.
Step 1: Set Up Google Tag Manager’s Server-Side Container
Before configuring your custom domain, you’ll need to create a server-side container in Google Tag Manager. If you haven’t already done this, follow these steps:
-
Open Google Tag Manager: Log in to your GTM account and select the container you want to work with.
-
Create a New Container: In the Admin panel, click "Create Container" and choose "Server" as the container type. Give your container a name (e.g., "Server-Side Container") and click "Create."
-
Deploy a Cloud Server: GTM will guide you through deploying the server container using Google Cloud or another cloud provider. You’ll need to create a Google Cloud project and set up App Engine to host your server-side container. GTM offers a built-in setup process for this.
-
Deploy Your Tags: Once your server-side container is set up, you can configure tags to run through the server instead of directly from the browser. For example, you might move your Google Analytics tag to the server-side container.
Step 2: Set Up a Custom Domain for Your Tracking Server
Now that your server-side container is ready, you can configure a custom domain. This will allow your tracking requests to be routed through a domain that is branded for your business.
1. Purchase and Configure Your Domain
If you don’t already have a custom domain, you’ll need to purchase one through a domain registrar like GoDaddy, Namecheap, or Google Domains. If you want to use a subdomain of your existing website (e.g., tracking.yourwebsite.com
), you can manage this through your website’s DNS settings.
- For a subdomain: You’ll need to add a CNAME record to your DNS configuration that points your subdomain to your Google Cloud server. Typically, this will involve accessing your domain’s DNS settings, adding a new CNAME record, and entering the details provided by Google Tag Manager.
Example:
- Subdomain:
tracking.yourwebsite.com
- CNAME points to:
your-google-cloud-server-url.appspot.com
2. Update Your DNS Settings
Once you have your domain or subdomain ready, you’ll need to update the DNS settings to point to your Google Cloud server.
- Log into your domain registrar's account (e.g., GoDaddy, Google Domains, etc.).
- Navigate to the DNS management section.
- Create a CNAME record for the subdomain you want to use (e.g.,
tracking.yourwebsite.com
). - Set the CNAME value to the server address provided by Google Cloud (e.g.,
your-google-cloud-server-url.appspot.com
).
This step will route any traffic from tracking.yourwebsite.com
to your server-side container hosted on Google Cloud.
3. Configure SSL (HTTPS)
To ensure your custom domain is secure, you’ll need to set up an SSL certificate. This is required because most browsers and tracking platforms now mandate that data be sent over HTTPS, not HTTP.
Google Cloud provides an option to automatically manage SSL certificates through its App Engine setup. You can enable this during the container deployment process, or you can purchase an SSL certificate from a third-party provider and configure it manually through your hosting platform.
Here’s how to enable SSL in Google Cloud:
- Go to your Google Cloud Console and open your App Engine settings.
- In the "Settings" section, look for the option to enable a custom domain and apply an SSL certificate.
- Google Cloud will generate and manage the SSL certificate for your custom domain, ensuring that your server is secure.
Step 3: Update Google Tag Manager’s Server-Side Settings
Once your custom domain and SSL certificate are configured, the next step is to update the settings within your Google Tag Manager container so that it recognizes your custom domain.
- Go to Google Tag Manager: Open the server-side container you set up earlier.
- Navigate to Container Settings: In the container settings, look for the "Custom Domain" section.
- Enter Your Custom Domain: Add your custom domain (e.g.,
tracking.yourwebsite.com
) into the field and save the changes.
Google Tag Manager will now route all tracking requests through your custom domain, instead of the default appspot.com
URL provided by Google Cloud.
Step 4: Test Your Custom Domain
Before going live, it's essential to test your custom domain to ensure everything is working as expected.
- Use a Tag Testing Tool: Tools like Google Tag Assistant or GTM's built-in preview mode can help you verify that your tags are firing correctly through the custom domain.
- Check SSL Status: Use a tool like SSL Labs to confirm that your SSL certificate is correctly installed and that your domain is secure.
- Inspect Network Requests: In your browser’s Developer Tools (usually under the "Network" tab), look for any tracking requests and confirm they are being sent through your custom domain.
Setting up a custom domain for Google Tag Manager’s server-side tracking is a critical step in ensuring better data accuracy and privacy. By routing your tracking requests through a branded domain, you avoid potential issues with ad blockers and improve user trust. While the process may seem technical at first, following these steps will help you configure your custom domain and enhance your server-side tracking setup.
With this setup in place, your business will have greater control over its data collection, paving the way for more effective and compliant tracking strategies.