Limited Offer: Get 2 Months FREE on annual plans, or get Lifetime Plan Claim Offer

Menu

Conversion API (CAPI) Setup for Facebook, TikTok, Google: Unified Implementation Guide

# Unified Conversion API Implementation: Streamline Facebook, TikTok, and Google with Server-Side GTM In today's privacy-first digital landscape, reliable conversion tracking is critical for optimizing ad campaigns. Platforms like Facebook, TikTok, and Google have introduced server-side Conversion APIs (CAPI) to enhance data accuracy and resilience against browser restrictions. However, implementing multiple APIs separately can lead to code bloat, maintenance nightmares, and inconsistent data. This guide presents a unified approach using server-side Google Tag Manager (sGTM) to send events to all three platforms from a single container, eliminating redundant client-side tags. ## Why a Unified Server-Side Strategy? The shift toward server-side tagging addresses several pain points: - **Data Accuracy**: By bypassing browser limitations (ad blockers, ITP), server-side CAPI ensures that conversions, even those from users who opt out of cookies, are still captured. - **Performance**: Removing multiple third-party scripts from your website speeds up page loads and improves user experience. - **Simplified Governance**: Centralizing tracking logic in one server-side container reduces code duplication and makes it easier to manage tags, triggers, and data transformations. - **Enhanced Data Enrichment**: You can hash and normalize user data (email, phone) in a single place before forwarding it, ensuring compliance and consistency. However, setting up multiple conversion APIs can become complex if you try to implement each with separate client-side tags. A unified server-side container acts as a single endpoint that receives events from your website (via GA4 or a custom data stream) and then fans them out to the respective platforms. This not only reduces client-side complexity but also standardizes how data is collected and processed. ## Architecture Overview The architecture involves: 1. A **client-side data source** (e.g., your website) sending events to a server-side GTM container. 2. A **server-side GTM container** hosted on your own cloud infrastructure (e.g., Google Cloud Run, AWS) that receives HTTP requests, processes them, and forwards to multiple destinations. 3. **Tag configurations** for Facebook CAPI, TikTok Events API, and Google Ads Enhanced Conversions within the sGTM container. ## Step-by-Step Implementation ### 1. Set Up a Server-Side GTM Container If you haven't already, create a server-side container in Google Tag Manager. Deploy it using App Engine, Cloud Run, or a custom server environment. Note the container URL; it will be your data endpoint. ### 2. Configure Client-Side Data Ingestion The most common approach is to send events to your sGTM container from a GA4 web tag configured to forward data to a server-side measurement ID. In your client-side GTM container, set up a GA4 event tag with the `Send to server container` option enabled, pointing to your sGTM URL. Alternatively, you can use a custom JavaScript client to fire events directly, but GA4 integration provides built-in data modeling and event deduplication. ### 3. Create a Centralized Data Layer Define a consistent schema for the events you want to track (e.g., purchase, signup, lead). In your data layer, include all necessary parameters: `event_name`, `value`, `currency`, `transaction_id`, user data like `email`, `phone`, `first_name`, `last_name`, and any custom parameters. All platforms expect similar core information; by standardizing them upfront, you streamline the mapping. ### 4. Set Up Facebook Conversion API (CAPI) - In your sGTM container, add a new tag and choose the "Facebook Conversions API" tag type. - Configure the **Facebook Pixel ID** and an **Access Token** generated from Facebook Events Manager. - Define the event mapping: Select the trigger (e.g., "Purchase" event). Map the incoming parameters to Facebook's required fields. For example, map `event_name` to Facebook's standard event, `value` to `value`, `currency` to `currency`. For user data, use the "Advanced Matching" section to forward hashed `email`, `phone`, and external ID. You can use sGTM's built-in hashing functions or pre-hash on the client side. - Set **Event ID** to `transaction_id` to enable deduplication between browser pixel and server-side events. ### 5. Set Up TikTok Events API - Add a "TikTok Events API" tag in your sGTM container. - Obtain your **TikTok Pixel Code** and **Access Token** from the TikTok Events Manager. - Configure the event settings: Map standard events (e.g., `CompletePayment` for purchase). TikTok expects user data in plain text or hashed; use sGTM transformations to hash emails and phones with SHA256 if not already hashed. Map parameters like `content_type`, `content_id`, `quantity`, `price` for product-level reporting. - Include `event_id` for deduplication. ### 6. Set Up Google Ads Enhanced Conversions - In sGTM, add a "Google Ads Conversion Tracking" tag. - Enter the **Conversion ID** and **Conversion Label** from your Google Ads account. - Under "Enhanced Conversions", provide a user data source. You can use sGTM's data layer variables to pass first-party customer data (email, phone, address). Google will hash this data automatically. - For the conversion value, map the transaction revenue. Ensure your conversion trigger fires on the same event as Facebook/TikTok. ### 7. Implement Event Deduplication Deduplication is critical to avoid overcounting conversions. All three platforms support an `event_id` parameter to uniquely identify an event. Use the same `transaction_id` (or a generated unique ID) for the same conversion across platforms. This way, if a browser pixel fires alongside the server event, the platform can deduplicate based on that ID. ### 8. Test and Validate Use the sGTM **Preview** mode to inspect incoming requests and verify that each tag fires correctly and data is mapped properly. Then, use each platform's test tools: - **Facebook**: Pixel Helper Chrome extension and Test Events tool in Events Manager. - **TikTok**: TikTok Pixel Helper and Events Manager's test events. - **Google Ads**: Google Tag Assistant and the Conversions section in Google Ads. Confirm that conversions appear in each platform's reporting with correct values and that deduplication is working. ## Advanced Considerations ### Data Privacy and Consent Ensure your server-side setup respects user consent choices. Use the sGTM Consent API to conditionally fire tags based on consent status. You can forward consent signals from your CMP (Consent Management Platform) to the server container and configure each tag to only send data if proper consent is given. ### Custom Event Processing Sometimes events require enrichment before sending. In sGTM, you can use custom JavaScript variables or Transformations to manipulate data—for instance, mapping product arrays to TikTok's content parameters or filtering out sensitive information. ### Monitoring and Logging Set up monitoring for your sGTM container to catch errors. Google Cloud’s logging can help you debug failed requests. Regularly check the health of your server-side deployment. ## Conclusion A unified server-side approach to Conversion APIs for Facebook, TikTok, and Google provides a scalable, maintainable, and privacy-centric tracking solution. By centralizing with server-side GTM, you eliminate client-side clutter, reduce inconsistencies, and ensure high-quality conversion data for your ad platforms. Implement this guide to streamline your setup and gain a competitive edge in data-driven advertising.
Last updated: Apr 04 2026
AI Assistant
Hi! 👋 You are viewing Conversion API (CAPI) Setup for Facebook, TikTok, Google: Unified Implementation Guide. Need any help with this topic?