Conversion Tracking
14 minute read

How To Set Up Server Side Tracking: Fix Your Attribution And Stop Losing Conversions

Written by

Matt Pattoli

Founder at Cometly

Follow On YouTube

Published on
January 21, 2026
Get a Cometly Demo

Learn how Cometly can help you pinpoint channels driving revenue.

Loading your Live Demo...
Oops! Something went wrong while submitting the form.

You're staring at your Meta Ads dashboard at 11 PM on a Tuesday, and the numbers don't make sense. Your analytics platform shows 47 conversions this week. Meta reports 31. Google Analytics claims 39. Your CRM has records of 52 actual sales.

Which number is real? More importantly—which ads are actually working?

This isn't just a reporting headache. It's a $50,000 problem hiding in plain sight. When your tracking data conflicts across platforms, you're making budget decisions based on incomplete information. You're scaling campaigns that might not be performing. You're pausing ads that could be your best converters. And every day, the gap between what's happening and what you can measure gets wider.

The culprit? Client-side tracking—the traditional pixel-based approach that's been breaking down since iOS 14.5 dropped in 2021. Ad blockers strip your tracking scripts. Safari's Intelligent Tracking Prevention kills cookies after seven days. Privacy-focused browsers block third-party tracking by default. And your customers? They're bouncing between devices, clearing cookies, and using VPNs—all while your client-side tracking loses the thread.

Server-side tracking solves this. Instead of relying on browser-based pixels that users can block, server-side tracking captures data directly from your server and sends it to advertising platforms through secure API connections. No ad blockers. No cookie restrictions. No iOS limitations. Just clean, accurate data flowing exactly where you need it.

By the end of this guide, you'll have a bulletproof tracking infrastructure that captures every conversion, attributes revenue accurately across platforms, and gives your ad algorithms the complete data they need to optimize effectively. We'll walk through the entire implementation process step-by-step—from server setup to platform integration to advanced attribution configuration.

Understanding Server-Side Tracking Architecture

Before you start configuring servers and API endpoints, you need to understand what's actually happening when someone clicks your ad and converts. The architecture is simpler than it sounds, but getting it right makes the difference between accurate attribution and garbage data.

Traditional client-side tracking works like this: A user clicks your Facebook ad. They land on your website. Facebook's pixel (a JavaScript snippet) fires in their browser. The pixel sends conversion data back to Facebook. Simple, right? Except every step in that chain can break. Ad blockers kill the pixel. Privacy settings block the request. Cookie restrictions prevent proper attribution. And you're left wondering why Facebook can't see half your conversions.

With server side tracking, the data flow changes completely. When a user converts, your server captures that event directly—no browser involvement required. Your server then sends that conversion data to Facebook (or Google, or TikTok) through a secure API connection. The user's browser never touches the tracking code. Ad blockers can't interfere. Privacy settings don't matter. The data flows cleanly from your server to the ad platform.

Here's what happens in a complete server-side tracking flow: User clicks ad → Lands on your site → Takes action (purchase, signup, etc.) → Your server records the event → Server sends data to ad platform via API → Platform receives complete conversion data. Every step happens server-to-server, bypassing all the browser-based restrictions that break traditional tracking.

The key component that makes this work is the server container. Think of it as a middleman that sits between your website and advertising platforms. When your site captures an event, it sends that data to your server container. The container then formats and forwards that data to each advertising platform using their specific API requirements. One event from your site becomes properly formatted conversion data for Facebook, Google, TikTok, and any other platform you're running ads on.

This architecture requires three main components working together: First, your website needs to send event data to your server (usually through a data layer). Second, you need a server container to receive and process that data (Google Tag Manager Server-Side or a custom solution). Third, you need API connections configured for each advertising platform you want to send data to. Get all three components working correctly, and you have bulletproof tracking that captures every conversion.

The technical implementation varies depending on your stack, but the concept remains the same: move tracking from the client (browser) to the server. Instead of relying on pixels that users can block, you're using direct server-to-server communication that nothing can interfere with. This is why server side tracking tools have become essential for serious advertisers—they provide the infrastructure to make this architecture work without building everything from scratch.

Setting Up Your Server Infrastructure

You can't run server-side tracking without a server. That sounds obvious, but this is where most implementations fail—choosing the wrong hosting setup or skipping critical configuration steps that cause tracking to break under load.

You have three main options for server infrastructure: Google Cloud Platform (GCP), Amazon Web Services (AWS), or a dedicated tracking platform that handles the server setup for you. For most advertisers, GCP is the simplest starting point because it integrates directly with Google Tag Manager Server-Side. AWS works if you're already invested in their ecosystem. Dedicated platforms like Cometly eliminate server management entirely, but we'll cover the manual setup first so you understand what's happening under the hood.

If you're going the GCP route, start by creating a new project in Google Cloud Console. Navigate to the Tag Manager section and select "Server Container." Google will walk you through provisioning a Cloud Run instance—this is the actual server that will receive and process your tracking data. The default configuration (1 CPU, 512MB memory) works for sites with under 100,000 monthly visitors. Beyond that, you'll need to scale up to prevent data loss during traffic spikes.

Here's the critical part most guides skip: configuring your server URL and DNS settings. Google assigns your server a default URL (something like "https://server-abc123.run.app"), but you should never use this directly. Instead, set up a custom subdomain on your domain (like "tracking.yourdomain.com") and point it to your server container. This serves two purposes: it makes your tracking requests look like first-party traffic (harder to block), and it allows you to migrate servers later without breaking your implementation.

To configure the custom domain, add a CNAME record in your DNS settings pointing your subdomain to the Google Cloud Run URL. Then, in your server container settings, add your custom domain and enable HTTPS. Google automatically provisions an SSL certificate through Let's Encrypt. This process takes 10-15 minutes. Don't skip the HTTPS step—browsers will block non-secure tracking requests, and you'll lose data without realizing it.

Once your server is running, you need to configure the server container itself. Log into Google Tag Manager and create a new server container (separate from your web container). This is where you'll set up the tags, triggers, and variables that control how your server processes incoming data and sends it to advertising platforms. The server container works similarly to the web container you're probably familiar with, but instead of firing tags in a browser, it processes server-side requests and makes API calls to ad platforms.

The final infrastructure piece is monitoring and scaling. Set up Cloud Monitoring in GCP to track your server's CPU usage, memory consumption, and request latency. If you see consistent CPU usage above 70% or request latency above 500ms, your server is struggling and you're likely losing data. Scale up to 2 CPUs and 1GB memory. For high-traffic sites (500k+ monthly visitors), consider running multiple server instances behind a load balancer to ensure zero data loss during traffic spikes.

Security matters here more than most people realize. Your server container will be receiving data from your website and sending it to advertising platforms. Enable Cloud Armor to protect against DDoS attacks. Set up firewall rules to only accept traffic from your domain. Configure authentication for your server container admin panel. A compromised server container means compromised tracking data—and potentially compromised customer information if you're passing PII through your tracking setup.

Configuring Data Collection and Event Tracking

Your server is running, but it's not receiving any data yet. This is where you configure your website to actually send events to your server container, and where most implementations break because of incomplete data layer setup or missing event parameters.

The foundation of server-side tracking is the data layer—a JavaScript object on your website that contains all the information about user actions and page context. If you're already using Google Tag Manager on your website, you probably have a basic data layer. But for server-side tracking, you need to enhance it with additional parameters that ad platforms require for proper attribution.

Here's what a complete data layer push looks like for a purchase event: It needs the event name ("purchase"), transaction ID, revenue value, currency, product details, and—critically—user identification parameters like email hash, phone hash, and client ID. Missing any of these parameters means incomplete data reaching your ad platforms, which degrades attribution quality and algorithm performance. Implementing proper customer journey tracking ensures you capture all necessary touchpoints throughout the conversion path.

Start by auditing your current data layer implementation. Open your browser console on a conversion page and type "dataLayer" to see what's currently being tracked. You'll probably see basic events like page views and clicks, but conversion events are often missing critical parameters. For e-commerce sites, you need product IDs, categories, quantities, and prices for each item. For lead gen, you need form field values (hashed if they contain PII). For SaaS, you need subscription tier, billing frequency, and trial status.

Once your data layer is properly configured, you need to set up your web container to send that data to your server container. In Google Tag Manager (web container), create a new tag using the "Google Analytics: GA4 Event" tag type, but instead of sending data directly to GA4, configure it to send to your server container URL. Set the "Server Container URL" field to your custom domain (tracking.yourdomain.com). This tag will fire on your conversion events and forward the data to your server for processing.

The tricky part is maintaining user identity across the client-server boundary. When a user clicks your ad, Facebook (or Google, or TikTok) appends tracking parameters to your URL—things like fbclid, gclid, or ttclid. Your website needs to capture these parameters and include them when sending events to your server. Without these click IDs, ad platforms can't attribute conversions back to specific ads. Set up URL parameter capture in your data layer, store the values in cookies or local storage, and include them with every event you send to your server.

For accurate attribution, you also need to capture and hash user identifiers. When someone makes a purchase or submits a form, grab their email and phone number, hash them using SHA-256, and include the hashes in your data layer. Ad platforms use these hashed identifiers for advanced matching—connecting conversions to users even when click IDs are missing or expired. This is especially important for iOS users where click ID attribution often fails. Using specialized conversion tracking tools can automate much of this hashing and parameter management.

Test your data collection setup before moving forward. Use Google Tag Manager's preview mode to see exactly what data is being sent to your server container. Check that all required parameters are present, properly formatted, and contain actual values (not "undefined" or "null"). Fire a test conversion and verify that your server container receives the event with complete data. This testing step catches 90% of implementation issues before they cause data loss in production.

Integrating Advertising Platform APIs

Your server is receiving clean event data from your website. Now you need to configure it to send that data to your advertising platforms through their Conversion APIs. This is where server-side tracking delivers its real value—direct, unblockable data transmission to the platforms that need it.

Each advertising platform has its own API with specific requirements, authentication methods, and data formats. We'll start with Facebook's Conversion API (CAPI) since it's the most commonly implemented and has the clearest documentation. The setup process for other platforms follows a similar pattern, but with platform-specific variations in required parameters and authentication.

To set up Facebook CAPI, you need three things from your Facebook Business Manager: your Pixel ID, an Access Token, and a Test Event Code (for verification). Find your Pixel ID in Events Manager under your pixel settings. Generate an Access Token in Business Settings → Data Sources → Your Pixel → Settings → Generate Access Token. Make sure the token has "ads_management" permissions and doesn't expire (set it to "Never" in the expiration dropdown). Save this token somewhere secure—you'll need it for your server container configuration.

In your Google Tag Manager server container, add a new tag using the "Facebook Conversions API" tag type. Configure it with your Pixel ID and Access Token. Map your incoming event parameters to Facebook's required fields: eventname, eventtime, eventid, userdata (email, phone, etc.), and customdata (value, currency, contentids, etc.). The parameter mapping is critical—if Facebook receives data in the wrong format, events will be rejected and you'll lose conversions.

Here's where most implementations fail: Facebook requires specific data formats for user information. Emails must be lowercase and trimmed of whitespace before hashing. Phone numbers must be in E.164 format (country code + number, no spaces or special characters). First and last names must be lowercase. Cities must be lowercase with spaces removed. Get any of these formats wrong, and Facebook can't match the conversion to a user, which degrades your attribution quality and ad performance. A robust marketing tracking system handles these formatting requirements automatically.

The event_id parameter deserves special attention. This is a unique identifier for each conversion that prevents duplicate reporting when you're running both client-side pixels and server-side API calls (which you should be doing for maximum coverage). Generate a random UUID for each conversion on your website, send it to both your pixel and your server container, and include it in both tracking calls. Facebook uses this ID to deduplicate events, ensuring each conversion is only counted once even though it's being reported through two different channels.

For Google Ads, the setup process is similar but uses Google's Measurement Protocol for GA4 and Google Ads API for conversion tracking. You'll need your GA4 Measurement ID and API Secret (found in GA4 Admin → Data Streams → Your Stream → Measurement Protocol API Secrets). In your server container, add a "Google Analytics: GA4" tag configured to send data via Measurement Protocol. Map your events to GA4's expected parameters: clientid, userid (if available), events array with event names and parameters.

Google's attribution works differently than Facebook's. Instead of relying primarily on hashed user data, Google uses the gclid parameter appended to your URLs when users click Google Ads. Your server-side implementation must capture this gclid from the URL, store it (usually in a cookie), and send it with every conversion event. Without the gclid, Google can't attribute the conversion to the specific ad that drove it. For enhanced conversions, also send hashed email and phone data—Google uses this for additional matching when gclid attribution isn't available.

TikTok's Events API follows a similar pattern. You'll need your TikTok Pixel ID and Access Token from TikTok Events Manager. Add a server-side tag in GTM (you may need to use a custom template from TikTok's documentation), configure your credentials, and map your event parameters to TikTok's required format. TikTok requires the ttclid parameter for attribution (similar to Facebook's fbclid and Google's gclid), so ensure you're capturing and storing this value from your URL parameters. When implementing facebook tracking software alongside TikTok, make sure your event IDs are shared across platforms to enable cross-platform deduplication.

After configuring each platform's API connection, use their test event tools to verify data is flowing correctly. Facebook has a Test Events feature in Events Manager that shows real-time events as they're received. Google has a DebugView in GA4 that displays incoming events with full parameter details. TikTok has a Test Events tool in their Events Manager. Send test conversions from your website and verify they appear in each platform's testing interface with all required parameters properly formatted.

Advanced Attribution and Optimization

Basic server-side tracking is working—events are flowing from your site to your server to ad platforms. But you're still missing the advanced attribution features that separate good tracking from great tracking. This section covers the configurations that maximize attribution accuracy and give your ad algorithms the complete data they need to optimize effectively.

First, implement attribution window customization. By default, most platforms use a 7-day click and 1-day view attribution window. But if your sales cycle is longer (common for high-ticket products or B2B), you're missing conversions that happen outside these windows. In Facebook Events Manager, extend your attribution window to 28-day click and 7-day view. In Google Ads, adjust your conversion window settings to match your actual sales cycle. Your server-side implementation should track and send conversion data regardless of how long ago the click happened—let the platform's attribution window settings determine what gets credited.

Cross-device attribution is where server-side tracking really shines. When you're sending hashed email and phone data with every conversion, platforms can match conversions to users even when they clicked an ad on mobile but converted on desktop (or vice versa). But this only works if you're consistently collecting and hashing user identifiers across all devices and sessions. Implement email capture early in your funnel (newsletter signup, account creation, etc.) and persist that hashed email through the entire customer journey. When the user eventually converts, your server sends that hashed email with the conversion event, enabling the platform to attribute the conversion even if the original click ID has expired.

Value-based optimization requires sending accurate revenue data with every conversion. This seems obvious, but most implementations get it wrong by sending gross revenue instead of profit, or by including tax and shipping in the conversion value when they shouldn't. Configure your server-side tracking to send the exact value you want to optimize for—usually net revenue or profit margin. For e-commerce, this means revenue minus cost of goods sold and shipping costs. For lead gen, this might be the average customer lifetime value for that lead type. The more accurate your conversion values, the better your ad platform's algorithms can optimize for profitable conversions instead of just volume. Understanding facebook attribution tracking helps you configure these value parameters correctly for optimal campaign performance.

Implement offline conversion tracking for businesses where the sale happens after the initial conversion event. If you're tracking leads that close days or weeks later, your ad platforms need to know which leads actually became customers. Set up a system to send offline conversion events to your server container when leads close. Include the original eventid or clickid so platforms can match the offline conversion back to the original ad click. This closed-loop attribution is essential for lead gen businesses—without it, you're optimizing for lead volume instead of lead quality.

Custom conversion events give you granular control over what you're optimizing for. Instead of just tracking "Purchase," set up separate conversion events for high-value purchases, repeat purchases, and first-time purchases. Create custom events for key micro-conversions like "Added to Cart," "Initiated Checkout," and "Viewed Product." Configure your server to send these events to your ad platforms, then create separate campaigns or ad sets optimizing for each event type. This allows you to run top-of-funnel campaigns optimizing for "Viewed Product" while running retargeting campaigns optimizing for "Purchase."

Data quality monitoring is the final piece most implementations miss. Set up alerts in your server container to notify you when event volume drops significantly, when required parameters are missing, or when API calls start failing. Monitor your platform's attribution reports daily to catch discrepancies early. If Facebook suddenly shows 50% fewer conversions, you need to know immediately—not three days later when you've already wasted budget on campaigns the algorithm couldn't optimize properly. Leveraging comprehensive tools for how to use marketing analytics enables you to spot these issues quickly and maintain data quality across all platforms.

The real power of server-side tracking emerges when you combine it with proper attribution modeling and continuous optimization. You're not just fixing broken tracking—you're building a data infrastructure that captures every conversion, attributes it accurately across devices and platforms, and gives your ad algorithms the complete picture they need to find and convert your best customers. That's the difference between guessing which ads work and knowing exactly where every dollar of revenue came from.

Ready to elevate your marketing game with precision and confidence? Discover how Cometly's AI-driven recommendations can transform your ad strategy—**Get your free demo** today and start capturing every touchpoint to maximize your conversions.

Get a Cometly Demo

Learn how Cometly can help you pinpoint channels driving revenue.

Loading your Live Demo...
Oops! Something went wrong while submitting the form.