Skip to content
Learn how you can future-proof your tracking by going server-side. This guide covers the key concepts, practical setups, and strategies you need to stay ahead in a privacy-first world. From Google Analytics and Ads to hybrid solutions, discover actionable steps to increase data accuracy and improve ROAS.
Resources / Guides / Server-side tagging and the future of tracking

A full guide to how to set up server-side tracking

Your marketing data is only as good as the system that collects it. So server-side tracking isn’t just a technical shift, it’s a smarter way to make sure your data is clean, consistent, and under your control.

By moving tracking to your own server, you create a single, reliable source of truth. That means less guesswork, fewer blind spots, and more confidence in the insights that drive your campaigns.

This guide walks you through the step-by-step process of how to set up server-side tracking for Google Analytics 4, Google Ads, and Facebook Ads.

Key takeaways

  • Server-side tracking offers enhanced data accuracy, consistency, and control compared to client-side methods.
  • Server-side tracking can be set up with Google Analytics 4, Google Ads, and Facebook Ads, among other platforms.
  • Google Tag Manager Server-side is the recommended and an easy method for implementation.
  • Infrastructure preparation, including hosting and GTM Server-side container deployment, is required.
  • Each platform (GA4, Google Ads, Facebook Ads) requires specific server-side tag configurations and API access.
  • Thorough testing and continuous monitoring of logs, data validation, and performance are crucial for success.
  • Common issues include missing click identifiers, API rejections, and session continuity problems.

What is server-side tracking?

Server-side tagging or tracking is an updated way of handling your data, which puts you in control. This enables you to meet data privacy obligations, get better quality data for marketing initiatives,potentially improve ROAS, and build trust with your customers.

In a client-side setup, analytics and advertising platforms collect information directly from the browser. While simple, this approach can be fragmented and difficult to oversee. This makes it harder to comply with global privacy laws like the EU’s General Data Protection Regulation (GDPR)

Server-side tagging reverses that flow. All data collected is sent to your own server first, where it can be processed, standardized and/or enriched, and then forwarded securely to the platforms you choose. 

Rather than each platform collecting data independently — with your company still responsible for data privacy and processor operations despite limitations on your visibility and control — you create a single, reliable checkpoint between your digital experience and your data ecosystem.

Video Preview
Video Preview

We need your consent to load the YouTube Video service!

We use a third party service to embed video content that may collect data about your activity. Please review the details and accept the service to watch this video.

powered by Usercentrics Consent Management Platform

How to set up server-side tracking 

Setting up server-side tracking involves multiple moving parts. The key is to start with your most valuable conversion actions and expand from there.

However, before diving into platform-specific setups, you’ll need to prepare your infrastructure. This means choosing between Google Tag Manager (GTM) Server-side (the most common approach) or direct API integrations. 

GTM Server-side offers easier implementation for most businesses, while direct APIs provide maximum customization.

You’ll also need to decide on your hosting preference. Google Cloud Platform integrates seamlessly with GTM Server-side, but AWS, Azure, or other cloud providers work equally well. Choose a region close to your primary audience to minimize latency, as slow server responses can impact attribution accuracy.

How to set up server-side tracking for Google Analytics 4

This guide covers setting up server-side tracking for GA4 using a GTM Server container. The GTM server container acts as a proxy between your website and GA4, enabling more control over data collection, privacy, and tag management. 

This is the most common and recommended way to implement server-side tagging for GA4. If you are not using GTM, this guide may not apply directly, as alternative server implementations require different setup steps.

Create and deploy your server container

  1. Log into Google Tag Manager and click Create Account (or add to existing).
  2. Select Server as your container type and name it something like Your Site Server Container.
  3. Click Create and note the container ID that appears.
  4. In Google Cloud Platform, go to the Marketplace and search for Tag Manager Server-side.
  5. Click on the official Google solution and hit Launch.
  6. Choose your project and billing account.
  7. Select a region close to your users (us-central1 for US traffic, europe-west1 for EU.)
  8. Set machine type to e2-micro for testing (you can scale up later.)
  9. Click Deploy and wait for the deployment to complete.
  10. Copy the server URL from the deployment summary. You’ll need this later.
  11. Go back and open your server container in Google Tag Manager.
  12. Go to the Clients section.
  13. Make sure a Google Analytics: GA4 client exists. If not, create one by selecting Add Client, then Google Analytics: GA4 (Web) and save.
  14. Check settings for Default GA4 paths (like /collect, /g/collect, and /j/collect) to ensure requests are being claimed correctly.

Configure your website to send data to your server

  1. Go back to your client-side GTM container (your website’s container.)
  2. Click on your Google Tag.
  3. In the Fields to Set section, click Add Field.
  4. Set Field Name to server_container_url.
  5. Set the Value to your server container URL from step 10.
  6. Save the tag and publish your container.

Set up server-side tags

  1. Switch to your server container in GTM.
  2. Go to Tags and click New.
  3. Choose the tag type Google Analytics: GA4. This single tag type is used to send all your data to GA4, whether it’s for page views, events, or ecommerce.
  4. Enter your GA4 Measurement ID (starts with G-.)
  5. Set the Tag name to something descriptive, like GA4 Page View.
  6. This is the most critical step. Instead of using a generic All Pages trigger, you will create a custom trigger to ensure the tag only fires when a page_view request is received from your website.
  7. Click the Triggering box at the bottom.
  8. Click the + icon to add a new trigger.
  9. Choose the Custom trigger type.
  10. Under Trigger Configuration, set the following conditions: Client Name equals Google Analytics: GA4 and Event Name equals page_view.
  11. Save the trigger with a name like Client – GA4 page_view.
  12. Go back to your tag and save it.

If you are sending other events, e.g. clicks, downloads, or custom events, you do not need to create a new GA4 configuration tag. You just need a new Google Analytics: GA4 tag for each event you want to send.

Test your setup

  1. In your server container, click Preview.
  2. Enter your website URL and click Connect.
  3. Visit your website in the preview tab.
  4. Check that events appear in your server container’s debug panel.
  5. Verify events show up in GA4’s real-time reports within a few minutes.
  6. If everything looks good, publish your server container.

How to set up server-side tracking for Google Ads

Google Ads server-side conversion tracking uses the same server setup as GA4 but requires extra configuration to optimize your campaigns.

Create server-side conversion actions

  1. Log into Google Ads and go to Tools & Settings > Measurement > Conversions.
  2. Click the blue plus button to create a new conversion action.
  3. Select Website as your conversion source.
  4. Enter your website’s domain and click Scan.
  5. On the next screen, scroll down and select Create a conversion action manually.
  6. Name your conversion (e.g. Purchase – Server Side.)
  7. Set your category, value, and count settings as needed.
  8. Choose your attribution model and click Done.
  9. Click Save and continue.
  10. Select Use Google Tag Manager and note the Conversion ID and Conversion Label, you’ll need these next.

Set up server-side conversion tags

11. In your GTM server container, go to Tags then New.

12. Choose Google Ads Conversion Tracking as your tag type.

13. Enter the Conversion ID and Conversion Label you noted earlier.

14. Name the tag something like Google Ads Purchase Conversion.

15. In the Triggering section, create a new custom trigger that fires only when the conversion event is received from your website.

16. Set the trigger conditions to:

  • Client Name equals Google Analytics: GA4
  • Event Name equals <your-conversion-event-name> (e.g. purchase, form_submit, etc.)

17. Under Conversion Parameters, add any additional fields you need to pass, such as value and currency, by selecting the corresponding data from the incoming event.

18. To ensure proper attribution, add a parameter named gclid and set its value to the built-in variable gclid.

19. Save the tag.

Test conversion tracking

20. Go to Tools & Settings > Conversions in your Google Ads account.

21. Find your new conversion action and click on it. You should see a status of No recent conversions.

22. Perform a test purchase or conversion on your website. Ensure you include the gclid parameter in the initial URL (e.g., www.yoursite.com/?gclid=test.)

23. Within three hours, check your Google Ads conversions report.

24. Verify the conversion appears and that the data (value, currency, etc.) is correct.

How to set up server-side tracking for Facebook Ads

Facebook’s Conversions API lets you send data about user actions, like purchases or sign-ups, directly from your server to Facebook. To set it up, you’ll need to generate access tokens and configure server-side tags, so your server can securely communicate these events to Facebook.

Set up Conversions API access

  1. Go to Facebook Business Manager and select your business account.
  2. Click on Events Manager from the main menu.
  3. Select your Facebook Pixel from the list.
  4. Click on the Settings tab at the top.
  5. Scroll down to find the Conversions API section.
  6. Click Generate access token.
  7. Copy it immediately and store it securely. You’ll need it for your server setup.

Verify your domain

  1. Still in Events Manager, go to Settings and find the Domains section.
  2. Click Add next to domains.
  3. Enter your website domain (without https://.)
  4. Choose your verification method. The HTML file upload is often the easiest.
  5. Download the verification file and upload it to your website’s root directory.
  6. Click Verify to complete domain verification. 

Install Facebook Conversions API tag

  1. In your GTM server container, go to Templates and click Search Gallery.
  2. Search for Facebook Conversions API and click on the official template.
  3. Click Add to workspace to install it.
  4. Go to Tags and create a new tag.
  5. Choose Facebook Conversions API as your tag type.
  6. Enter your Pixel ID (found in Events Manager.)
  7. Paste the access token you copied earlier.
  8. Choose the standard event you want to track (e.g., Purchase, Lead.)
  9. Set up any event parameters like value, currency, or content_ids by referencing data from the incoming event payload.
  10. In the triggering section, create a new custom trigger that fires only when the conversion event is received from your website.
  11. Set the trigger conditions to:
  • Client Name equals Google Analytics: GA4
  • Event Name equals <your-conversion-event-name> (e.g., purchase, form_submit, etc.)
  1. Save the tag.

Configure customer data

  1. In your client-side GTM container, ensure that user data (e.g. email, phone number, etc.) is included in the event payload sent to your server. This is typically done by adding user_data parameters to your GA4 tags.
  2. In the same tag in your server container, expand Customer Information Parameters.
  3. Add fields for email, phone, first name, last name, and so on, if they are available in the incoming event data.
  4. Make sure these fields are set to hash the data automatically. The Facebook CAPI tag handles this for you.
  5. Set Action Source to website.
  6. Save the tag.

Test your Conversions API setup

  1. In Facebook Events Manager, go to the Test Events tab.
  2. Select your pixel from the dropdown and copy the Test Event Code.
  3. Perform a test conversion on your website.
  4. Check that the event appears in the Test Events feed within a few minutes.
  5. Look for the Conversions API badge next to the events to confirm they are coming from your server.

Look for a high Event Match Quality score, as this confirms your customer data is being matched correctly.

Learn how to set up Server-Side Tagging step by step in our 60-minute on-demand course.

Debugging and monitoring server-side tracking setup

Once your server-side tracking is running, you need systems in place to catch problems before they cost you data. Server-side setups have more moving parts than client-side tracking, which means more things can go wrong.

The good news is that most issues follow predictable patterns. Missing or misattributed conversions usually trace back to common causes, which we’ll cover in the sections below.

Logging and visibility

Logs are your first line of defense. Set up logging at every stage of your tracking pipeline. From when events are received from your website, how they’re processed on your server, and whether they’re successfully sent to each analytics platform.

Your logs should provide enough detail to troubleshoot effectively without storing sensitive customer information. Include event types, timestamps, success or failure status, and any API error messages.

In addition to logging, set up alerts for critical failures. If your server stops receiving data from your website or APIs start rejecting requests, you need to know immediately. Delayed detection can result in permanent data loss.

Data validation and quality checks

Validation helps prevent errors before they reach your analytics platforms. Ensure required fields are present, values fall within expected ranges, and any customer data is properly hashed.

Regularly compare data across platforms. For example, if GA4 shows 100 conversions, but Google Ads only shows 50 for the same period, investigate potential causes, such as differences in attribution windows, conversion definitions, or technical issues.

Also, monitor data freshness and delivery timing. Most analytics platforms rely on recent data for accurate attribution, so delays in server-side processing can directly affect performance and reporting.

Performance monitoring

Server response times have a direct impact on attribution accuracy. Monitor your server under different traffic loads and optimize database queries or external API calls that could introduce latency.

Keep an eye on server resources, including CPU usage, memory, and network throughput. Server-side tracking can be resource-intensive during spikes in traffic, and performance degradation often leads to lost data.

If you’re using cloud-hosted solutions, monitor costs alongside performance. Unexpected traffic surges can increase hosting costs, while under-provisioned resources may cause tracking failures.

Troubleshooting common issues

Many attribution problems stem from missing or incorrect click identifiers. Make sure GCLID, FBCLID, and other platform-specific parameters are captured and transmitted correctly across your pipeline.

API rejections often indicate data formatting issues. Review platform documentation regularly, as validation rules can change and previously working setups may break.

If conversions appear missing, check attribution windows and timing. Conversions sent long after the original interaction may not be attributed correctly, particularly if your settings don’t align with your business model.

Finally, session continuity issues can disrupt user journey tracking. Ensure your server-side implementation maintains consistent user identification across sessions and devices whenever possible.

Set up server-side tagging the right way

Server-side tagging setup comes down to three steps: deploy your server infrastructure, configure your platforms, and test everything thoroughly. The technical details matter, but the process is manageable when you tackle one platform at a time.

Many businesses can see cleaner data within the first week and better campaign performance within a month. The key is starting with your most important conversions and expanding from there, rather than trying to migrate everything at once.