Pay Per Click
20 minute read

How to Set Up Conversion API: A Complete Step-by-Step Tutorial for Accurate Ad Tracking

Written by

Grant Cooper

Founder at Cometly

Follow On YouTube

Published on
March 7, 2026

You're running ads across Meta, Google, and TikTok. Your dashboard shows clicks, but conversions aren't matching up. Some sales aren't being attributed to any source. Others seem to vanish between the ad click and your CRM. Sound familiar?

The problem isn't your campaigns—it's how conversion data reaches your ad platforms. Browser-based tracking, the method most marketers rely on, is breaking down. iOS privacy updates block tracking. Cookie restrictions limit visibility. Ad blockers erase the trail entirely.

The result? Your ad platforms are optimizing with incomplete data, and you're making budget decisions based on partial information.

Conversion API changes this entirely. Instead of relying on browsers to report conversions, CAPI sends data directly from your server to ad platforms. No browser limitations. No privacy restrictions blocking the signal. Just clean, reliable conversion data flowing exactly where it needs to go.

This tutorial walks you through the complete setup process, from gathering credentials to validating live data. Whether you're implementing Meta's Conversion API, Google's server-side tracking, or connecting multiple platforms at once, you'll have a working system by the end.

No deep technical background required. Just follow each step, and you'll have server-side tracking feeding your ad platforms the data they need to optimize effectively.

Step 1: Gather Your Platform Credentials and Access Requirements

Before touching any code or configuration, you need the right access and credentials for each platform you're connecting. Missing a single token or permission level will halt your entire setup.

Start by listing every ad platform you run campaigns on. Meta, Google, TikTok, Snapchat—write them all down. Each platform has different credential requirements, and you'll need to collect them systematically.

For Meta Conversion API: Log into your Business Manager and navigate to Events Manager. Find your Pixel ID—it's a 15-digit number that identifies your tracking pixel. Then generate an access token by going to Settings > Generate Access Token. This token authenticates your server's requests to Meta's API. For detailed instructions, see our Facebook Conversion API setup guide.

For Google Ads: You'll need your Conversion Action ID and Google Ads API credentials. Navigate to Tools & Settings > Conversions in your Google Ads account. Each conversion action has a unique ID you'll use to send server-side events. If you're using Google Analytics 4, you'll also need your Measurement ID and API Secret from the Admin section.

For TikTok: Access your TikTok Events Manager to find your Pixel ID and generate an Access Token. TikTok's setup is similar to Meta's—both require a pixel ID and authentication token for server-side event transmission.

Next, verify your permissions. You need admin access to both your ad accounts and your website's backend. If you're working with a developer or agency, confirm they have the necessary access before starting implementation.

Document your current tracking setup in a spreadsheet. List every conversion event you're currently tracking: purchases, leads, sign-ups, add to cart actions. Note which events are tracked via pixel, which are captured in your CRM, and which fall through the cracks entirely.

This gap analysis shows exactly what Conversion API needs to solve. If you're losing visibility on phone call conversions or deals that close days after the initial ad click, mark those specifically—they're prime candidates for server-side tracking.

Create a secure document with all credentials. Store pixel IDs, access tokens, and API secrets in a password manager or secure note system. You'll reference these repeatedly during setup, and losing track of a single token means regenerating it and starting over.

Success indicator: You have a complete list of platforms, all necessary credentials documented, admin access verified, and a clear picture of which conversion events need server-side tracking.

Step 2: Choose Your Implementation Method

You have two paths for implementing Conversion API: build it yourself with custom code, or use a platform that handles the technical complexity for you. The right choice depends on your resources, technical capacity, and how many platforms you're connecting.

Manual server-side setup gives you complete control. You write the code that captures conversion events on your server, formats them according to each platform's API specifications, and sends them directly. This approach works well if you have dedicated developers, a single ad platform to connect, and the bandwidth to maintain custom code as APIs evolve.

The tradeoff? You're responsible for everything. When Meta updates their API requirements, you update your code. When you add a new conversion event, you modify your implementation. When something breaks at 2 AM, you're the one troubleshooting.

For Meta's CAPI specifically, you'll need to set up server endpoints that receive conversion data, hash user information according to Meta's requirements, structure the event payload correctly, and handle API authentication. Then multiply that complexity by every additional platform you want to connect.

Partner integration platforms like Cometly handle the technical implementation for you. You connect your data sources once, and the platform manages event formatting, API connections, deduplication, and ongoing maintenance across all your ad platforms simultaneously. Explore our comparison of the best Conversion API tools to find the right solution for your needs.

These platforms excel when you're running campaigns across multiple channels. Instead of building separate integrations for Meta, Google, TikTok, and Snapchat, you connect your website and CRM once. The platform then syncs conversions to every ad platform automatically, maintaining proper formatting and handling API updates as they happen.

The tradeoff here is less granular control over the exact implementation details. But for most marketing teams, that's not a real limitation—you care about reliable data flow, not the specific code that makes it happen.

Decision framework: Choose manual setup if you have in-house developers with API experience, you're only connecting one or two platforms, and you have ongoing development capacity for maintenance. Choose a platform solution if you're connecting multiple ad platforms, your team focuses on marketing rather than engineering, or you want to start capturing server-side data this week instead of next quarter.

Consider your maintenance capacity honestly. A custom integration isn't a one-time project—it requires ongoing attention as APIs change, new conversion events are added, and tracking requirements evolve. If that sounds like a distraction from your core marketing work, a platform solution makes more sense.

For teams managing significant ad spend across multiple platforms, the speed and reliability of a unified solution typically outweighs the flexibility of custom code. You can have server-side tracking running across all platforms in days instead of months, and your team stays focused on optimizing campaigns rather than debugging API calls.

Step 3: Configure Your Server-Side Event Tracking

Server-side events require precise formatting. Each conversion you send needs specific parameters that tell ad platforms what happened, when it happened, who it happened to, and what it's worth. Get the structure wrong, and platforms will reject your events entirely.

Every server-side event contains four core components: event name, event time, user data, and custom data. Let's break down each one.

Event name identifies what action occurred. Use standard event names that platforms recognize: Purchase, Lead, CompleteRegistration, AddToCart, InitiateCheckout. These standard names trigger platform optimization algorithms correctly. Custom event names work for specialized tracking, but standard names unlock better ad delivery.

For Meta, the standard event names are case-sensitive. "Purchase" works. "purchase" doesn't. Check each platform's documentation for their exact naming requirements—this small detail determines whether your events register correctly.

Event time must be a Unix timestamp marking when the conversion actually occurred. Not when you're sending the event, but when the user completed the action. If someone purchases at 2:00 PM but your server sends the event at 2:05 PM, use the 2:00 PM timestamp. Accurate timing helps platforms attribute conversions to the correct ad impressions.

Most server environments can generate Unix timestamps natively. In JavaScript, use Math.floor(Date.now() / 1000). In Python, use int(time.time()). The result should be a 10-digit number representing seconds since January 1, 1970.

User data is how platforms match your conversion to the person who saw your ad. Include every identifier you have: email address, phone number, first name, last name, city, state, zip code, country, and external ID if you use one.

Here's the critical part: all personally identifiable information must be hashed using SHA-256 before sending. Platforms don't want raw email addresses or phone numbers—they want hashed versions they can match against their own hashed user databases. Understanding CAPI match rate helps you optimize this user data matching process.

Hash each field individually. Don't hash the entire user object. If the email is "user@example.com", hash that specific string and send the result in the email field. Do the same for phone, name, and other identifiers.

Before hashing, normalize the data. Convert emails to lowercase. Remove spaces from phone numbers. Standardize country codes. A phone number sent as "555-123-4567" won't match the same number stored as "5551234567" in the platform's database. Normalization ensures your hashed values match theirs.

Custom data includes conversion-specific information like purchase value, currency, product IDs, and quantity. For purchase events, always include value and currency. For lead events, include lead quality scores or source information if you track them.

Value should be a number without currency symbols. If someone spent $49.99, send 49.99 in the value field and "USD" in the currency field. This data powers value-based optimization in your ad platforms.

Map each conversion event type to its required parameters. A Purchase event needs value and currency. A Lead event might include lead_quality or form_id. An AddToCart event should include content_ids and content_type to identify which products were added.

Test your event payload structure before going live. Most platforms provide event testing tools that show exactly what they're receiving. Send a test event and verify every parameter appears correctly: event name spelled right, timestamp in Unix format, user data properly hashed, custom data included.

If you're using a platform like Cometly, much of this formatting happens automatically. The platform handles hashing, timestamp conversion, and parameter mapping based on the data you send. But understanding the underlying structure helps you troubleshoot issues and verify everything is working correctly.

Step 4: Connect Your Data Sources and CRM

Browser pixels only capture what happens on your website. But conversions often occur elsewhere—in your CRM when a lead becomes a customer, on a phone call, or when someone fills out a form on a landing page. Connecting these data sources to your Conversion API setup ensures every conversion reaches your ad platforms.

Start with your CRM. Whether you use Salesforce, HubSpot, Pipedrive, or another system, it contains the most valuable conversion data: which leads closed, how much they spent, and how long the sales cycle took. This downstream data is exactly what ad platforms need to optimize for actual revenue, not just form submissions.

Direct CRM integrations vary by platform. Salesforce offers API access through connected apps. HubSpot provides webhook capabilities that trigger when deals change stages. Most modern CRMs support some form of real-time data export when specific events occur.

Set up a trigger for each conversion milestone you want to track. When a deal moves to "Closed Won", send a Purchase event to your ad platforms with the actual deal value. When a lead reaches "Marketing Qualified", send a Lead event. When an opportunity is created, send an InitiateCheckout event.

These CRM-based events should include the same user identifiers you collected initially: email, phone, name. This allows platforms to match the conversion back to the original ad click, even if weeks passed between the click and the closed deal.

Webhook connections provide real-time data flow from your backend systems to your Conversion API setup. When a conversion occurs, your system sends a POST request to a specified URL with the conversion data. Your server or integration platform receives this data, formats it correctly, and forwards it to your ad platforms.

For e-commerce platforms like Shopify or WooCommerce, webhooks trigger on specific events: order created, payment completed, refund processed. Configure these webhooks to send purchase data immediately when transactions occur, capturing conversions that might be missed by browser-based tracking. If you're on Shopify, our Shopify conversion tracking setup guide walks through this process in detail.

Landing page tools like Unbounce or Leadpages also support webhook notifications when forms are submitted. Connect these to your server-side tracking to capture leads that occur outside your main website.

Event deduplication becomes critical when you're running both pixel tracking and Conversion API. Without deduplication, platforms count the same conversion twice—once from the browser pixel, once from your server—inflating your conversion numbers and confusing optimization algorithms. Learn more about the differences in our Conversion API vs pixel tracking comparison.

Implement deduplication by assigning each conversion a unique event ID. When your browser pixel fires, it includes this ID. When your server sends the same conversion via CAPI, it includes the same ID. Platforms recognize the matching IDs and count the conversion only once.

For Meta, include the event_id parameter in both pixel and server events. For Google, use the transaction_id field. The ID should be unique to each conversion—typically an order number, form submission ID, or generated UUID.

Establish clear data flow: website conversion occurs → browser pixel fires with event ID → server receives conversion data → server sends CAPI event with same event ID → platform deduplicates and counts once. This ensures you get the benefits of both tracking methods without double-counting.

For teams using attribution platforms, this connection process simplifies significantly. Cometly, for example, integrates directly with major CRMs and e-commerce platforms, automatically handling webhooks, event formatting, and deduplication across all connected ad platforms. One integration captures conversions from all sources and syncs them everywhere.

Success indicator: Your CRM is connected and sending conversion events, webhooks are configured for all relevant systems, event IDs are being assigned consistently, and test events show proper deduplication working across pixel and server-side tracking.

Step 5: Validate Your Setup with Test Events

Before sending live conversion data, verify everything works correctly using platform testing tools. A single misconfigured parameter can cause all your events to fail silently, leaving you with broken tracking and no visibility into the problem.

Meta's Test Events tool shows exactly what your server is sending and whether Meta's API is accepting it. Access it through Events Manager → Select your pixel → Test Events tab. This interface displays incoming server events in real-time, showing every parameter, whether data is properly hashed, and if any errors occurred.

Send a test purchase event from your server. Within seconds, it should appear in the Test Events interface. Check that the event name is spelled correctly, the timestamp is a valid Unix timestamp, user data fields show as hashed values (long strings of letters and numbers, not readable email addresses), and custom parameters like value and currency are present.

If events aren't appearing, check your access token first. An invalid or expired token causes silent failures—your server sends the event, but Meta's API rejects it before it reaches Test Events. Regenerate your token if needed and update your server configuration. Our guide on how to fix Facebook Conversion API issues covers common troubleshooting scenarios.

Google's Tag Assistant and server-side debugging work differently. For Google Ads conversion tracking, events don't appear in a real-time test interface. Instead, check the API response your server receives. A successful event returns a 200 status code. Errors return specific codes indicating what went wrong: 401 for authentication issues, 400 for malformed requests.

For Google Analytics 4 server-side events, use the Measurement Protocol validation server. Send your event to the validation endpoint first (same format, different URL), and Google returns detailed feedback about whether the event is structured correctly.

Test every conversion event type you plan to track. If you're tracking Purchase, Lead, AddToCart, and InitiateCheckout events, send a test version of each. Verify that platform-specific parameters are included correctly—Purchase events need value and currency, AddToCart events need content_ids.

User data matching is where most setups fail. Platforms use your hashed user data to match conversions back to ad impressions. If your hashing is incorrect or data isn't normalized properly, match rates drop and attribution suffers.

Meta provides an Event Match Quality score that indicates how well your server events are matching to user profiles. Access this in Events Manager → Data Sources → your pixel → Overview tab. A score above 6.0 is good. Above 7.0 is excellent. Below 5.0 indicates problems with your user data.

Low match quality usually means missing user parameters or incorrect hashing. Check that you're sending email, phone, and other identifiers. Verify that values are normalized before hashing—lowercase emails, no spaces in phone numbers, proper country codes.

Common troubleshooting issues and solutions:

Events not appearing in Test Events: Verify your access token is current and has the correct permissions. Check that your server is actually sending requests—add logging to confirm the API call is being made. Ensure you're sending to the correct endpoint URL.

Authentication errors (401 status): Your access token is invalid, expired, or doesn't have permission to send events to this pixel. Generate a new token with the correct permissions and update your server configuration.

Missing parameters errors (400 status): Your event payload is missing required fields. Check that event_name, event_time, and user_data are all included. Verify the JSON structure matches platform requirements exactly.

Low Event Match Quality scores: Add more user data parameters to your events. Include email, phone, first name, last name, city, state, and country when available. Verify hashing is working correctly—hashed values should be 64-character hexadecimal strings for SHA-256.

Events delayed or not appearing: Check your server's internet connectivity and firewall settings. Some hosting environments block outbound API requests by default. Verify that requests to platform APIs aren't being blocked.

Run test events for at least 24 hours before launching with live data. This catches intermittent issues that might not show up in a single test. Monitor the testing tools during this period to ensure events flow consistently without errors.

Step 6: Launch and Monitor Your Conversion Data Quality

You've tested your setup. Events are flowing correctly. User data is matching. Now it's time to switch from test mode to production and start feeding real conversion data to your ad platforms.

Disable test mode in your implementation. If you're using platform testing tools, stop sending events there and start sending to the production API endpoints. For most platforms, this is a configuration change—switching from a test access token to your production token, or changing a single parameter in your API calls.

Verify live data flow immediately. Within minutes of going live, you should see real conversion events appearing in your ad platform dashboards. Meta's Events Manager shows recent events under the Activity tab. Google Ads displays conversion counts in the Conversions column of your campaigns.

Compare the conversion volume to your previous browser-only tracking. You should see an increase—server-side tracking captures conversions that browser limitations missed. If you're seeing fewer conversions than before, something is wrong with your implementation. Check that deduplication isn't removing valid conversions or that event IDs are being assigned correctly.

Event Match Quality monitoring is your primary health metric for Meta Conversion API. Check your EMQ score daily for the first week, then weekly after that. The score updates based on recent events, so you'll see it stabilize over a few days as live data flows.

If your score drops below 6.0, investigate immediately. Low match quality means platforms can't connect your conversions to ad impressions effectively, reducing optimization performance. Add more user parameters to your events, verify hashing is working correctly, and check that data normalization is happening before hashing.

Set up monitoring alerts for tracking failures. Most platforms offer notification systems that alert you when event volume drops significantly or when errors spike. Configure these alerts to email or Slack so your team knows immediately if tracking breaks.

For custom implementations, add server-side logging that tracks API response codes. If you start receiving 400 or 500 errors from platform APIs, you'll want to know before conversions stop flowing entirely. Log both successful events and failures so you can diagnose issues quickly.

Data quality comparison reveals the improvement from server-side tracking. Pull a report comparing the same time period before and after implementing Conversion API. Look at total conversions tracked, conversion value captured, and attribution to specific campaigns.

You should see conversions that weren't attributed before now being connected to their source campaigns. Purchases that occurred days after the initial ad click should now appear in your reporting. Phone call conversions and CRM-based conversions should be feeding back to the campaigns that drove them. Understanding conversion window attribution helps you interpret these delayed conversions correctly.

Monitor your ad platform optimization over the next two weeks. As algorithms receive better conversion data, you should see improved performance—better audience targeting, more efficient bidding, and campaigns optimizing toward actual revenue instead of just clicks or pageviews.

Check your attribution reporting for discrepancies between pixel and server-side data. Some difference is normal—server-side tracking captures more conversions. But if the numbers diverge dramatically, investigate whether deduplication is working correctly or if one tracking method is misconfigured.

For teams managing multiple ad platforms, unified attribution platforms like Cometly provide a single dashboard showing conversion data quality across all channels. Instead of checking Event Match Quality in Meta, conversion tracking in Google, and event validation in TikTok separately, you see everything in one place with alerts when any platform's data quality drops.

Success indicator: Live events are flowing to all connected platforms, Event Match Quality scores are above 6.0, monitoring alerts are configured, and you're seeing improved conversion visibility compared to browser-only tracking.

Your Conversion API Implementation Checklist

You now have server-side tracking sending reliable conversion data directly to your ad platforms. No browser limitations. No iOS restrictions blocking signals. Just clean, accurate data flowing exactly where it needs to go so your campaigns can optimize effectively.

Before you close this guide, run through this final checklist:

Credentials gathered and documented: All pixel IDs, access tokens, and API credentials are stored securely and accessible to your team.

Implementation method chosen: You've either built custom server-side code or connected a platform that handles the technical complexity across all your ad channels.

Events configured and mapped: Every conversion type has proper event names, required parameters, and correctly hashed user data.

CRM and data sources connected: Downstream conversions from your CRM flow back to ad platforms, and webhooks capture conversions from all relevant systems.

Test events validated successfully: Platform testing tools confirm your events are structured correctly, user data is matching, and deduplication is working.

Monitoring in place: You're tracking Event Match Quality scores, have alerts configured for tracking failures, and are comparing data quality to your previous browser-only setup.

Your next step: check your Event Match Quality scores 48 hours after launch. This gives platforms enough data to calculate accurate scores and shows whether your user data matching is performing optimally. If scores are below 6.0, revisit your user data parameters and hashing implementation.

For teams running campaigns across Meta, Google, TikTok, and other platforms simultaneously, managing separate Conversion API implementations for each platform creates ongoing maintenance complexity. Cometly streamlines this entire process by automatically syncing conversions to all your ad platforms while providing unified attribution across your entire marketing stack. You connect your data sources once, and Cometly handles event formatting, API connections, deduplication, and monitoring across every platform. Learn more about the Conversion API benefits that drive better campaign performance.

The platform's AI-driven recommendations analyze your cross-platform conversion data to identify which campaigns and channels actually drive revenue, not just clicks. This means you can make confident budget decisions based on complete, accurate attribution data instead of partial browser-based signals.

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.