Skip to content
FunnelGuard

Fix guide by FunnelsGuard

CAPI sending event_source_url of staging: how to fix it

TRK-182Medium impactCould addBy FunnelGuardPublished Updated
On this page

What this issue is

The Conversions API lets your server send events (such as Lead or Purchase) to Meta directly, alongside the browser Pixel. Each server event can include event_source_url, the full address of the page where the action happened. For website events Meta expects it, and it should be a page on your own verified domain.

This issue happens when that value points to something like https://staging.example.com/thank-you or a *.myshopify.com preview, while real customers are on https://www.example.com. It is usually caused by an environment setting, a hard-coded URL, or a plugin or server tag copied from staging to production.

Why it costs you leads or sales

Meta uses the source URL to understand where an event came from, and it checks it against your domain setup. A wrong domain can mean events are ignored, counted against the wrong place, or shown under a domain you do not own. That weakens attribution and gives the ad algorithm fewer reliable conversions to learn from, so campaigns can cost more per lead or sale.

The impact is usually medium: events still arrive, so nothing looks obviously broken. Reports just become less trustworthy. Staging events also pollute your real data if test purchases are sent to the live dataset.

Where the wrong URL gets in
  1. Visitor convertsForm or checkout on the live domain
  2. Server builds CAPI eventevent_source_url taken from a staging setting
  3. Meta receives eventDomain does not match your verified domain
  4. Attribution and optimisationWeaker signal for campaigns

The visitor converts on the live site, but the server builds the event with a staging URL.

How to check if your site has it

Check what URL your events carry
  1. Open Events Manager

    In Meta Events Manager, select your dataset (Pixel), then open the Test events or Overview tab.

  2. Look at server events

    Click a recent event marked as coming from the server (Conversions API) and read the event details for the source URL.

  3. Check the Diagnostics tab

    Look for warnings about domains or URLs that do not match your verified domain.

  4. Inspect your own payload

    Log the JSON your server sends to Meta, or open your server-side tag's preview, and read the event_source_url field.

  5. Search the code and settings

    Search your code, plugin settings and environment variables for the staging hostname.

What a wrong and a right payload look likejson
// Wrong
{"event_name":"Lead","event_source_url":"https://staging.example.com/thank-you","action_source":"website"}

// Right
{"event_name":"Lead","event_source_url":"https://www.example.com/thank-you","action_source":"website"}

How to fix it

The best fix is to take the URL from the real request the visitor made, not from a fixed setting. If you must use a setting, make it different for each environment and set the live value in production.

Fix by platform
  1. Check the site address

    Go to Settings > General and confirm WordPress Address and Site Address use your live domain. A database copied from staging often keeps the old one.

  2. Check your CAPI plugin

    Open the settings of the plugin that sends CAPI events (Meta's official plugin, a WooCommerce add-on or a tag plugin). Look for any fixed URL or domain field and update it.

  3. Search the database

    Search options and plugin tables for the staging hostname and replace it with a search-and-replace tool that handles serialised data.

Node.js: take the URL from the visitor's pagejavascript
// Browser: send the real page URL with your form or order data
fetch('/api/lead', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({ email, pageUrl: window.location.href })
});

// Server: use it in the Conversions API event
const event = {
  event_name: 'Lead',
  event_time: Math.floor(Date.now() / 1000),
  action_source: 'website',
  event_source_url: req.body.pageUrl,
  user_data: { em: [hashedEmail] }
};
Event source URL, before and after

Before

  • event_source_url is a staging address
  • Diagnostics may warn about domain mismatch
  • Staging and live events mix in one dataset

After

  • event_source_url is the live page the visitor was on
  • Domain matches your verified domain
  • Staging uses its own test dataset or sends nothing

How to confirm it's fixed

Confirm the fix
  1. Run a test conversion

    Submit a test lead on the live site. Use the Test events tab in Events Manager with your test event code if you want to see it right away.

  2. Read the server event

    Open the event marked as from the server and check the source URL is the live page.

  3. Recheck Diagnostics

    Wait for new events and make sure domain warnings clear.

  4. Remove the test code

    Take the test event code out of production once you have finished.

How to prevent it happening again

Prevention checklist
  • Keep the base URL in an environment variable, never hard-coded
  • Use a separate Pixel or dataset and access token for staging
  • Add an allowlist check for hostnames before sending events
  • Review CAPI settings after every site copy, migration or plugin update
  • Check Events Manager Diagnostics after each release
  • Verify your domain in Business Manager

How FunnelGuard handles this

FunnelGuard does not check this yet. Reading the event_source_url of server-side events is a possible future check, but it is not part of the product today, so do not rely on FunnelGuard for it.

What FunnelGuard does today is run your real journeys, such as a lead form or checkout, from the EU or the US on a schedule, and check each step and the tracking hits sent from the browser to platforms like Meta, GA4 and Google Ads. It also checks that test leads reach your inbox and CRM. If a step breaks, a failure is re-checked from a second region and you get one alert with a screenshot and a likely cause. That covers browser-side problems near this one, but not the content of your server-side payload.

To watch for this yourself, review the server events in Meta Events Manager after each release, keep an eye on the Diagnostics tab, and log your outgoing CAPI payloads with an alert on any hostname that is not on your allowlist. A free FunnelGuard plan (1 site, 2 journeys, daily checks) can still cover the journey itself.

Questions people ask

Why is my Conversions API sending a staging URL as event_source_url?

Usually the server reads the URL from a setting, environment variable or plugin option that was copied from staging, or it is hard-coded. It can also happen when production code runs behind a staging hostname. Search your code and settings for the staging domain and replace it.

What should event_source_url be in Meta CAPI?

It should be the full address of the page where the action happened, such as https://www.example.com/thank-you. It should be on your own domain, ideally one verified in Business Manager. Take it from the visitor's real request or page.

Is event_source_url required for the Conversions API?

Meta requires it for website events, which use action_source set to website. Leaving it out or sending a wrong value can cause events to be rejected or misread. Always send the live page URL.

How do I see which URL my CAPI events are sending?

In Meta Events Manager, open your dataset and click a recent event marked as coming from the server. The event details show the source URL. You can also log the JSON payload on your own server.

Can staging events hurt my Meta ad performance?

They can. Test events mixed into your live dataset add noise, and wrong domains can weaken attribution. Meta's optimisation then has less reliable data, which can raise your cost per result.

Does FunnelGuard detect a wrong event_source_url?

No. FunnelGuard does not check this yet, though it is a possible future check. It does run your real journeys and check browser-side tracking hits, so use Events Manager and payload logging for this issue.

How do I stop staging from sending events to my live Pixel?

Give staging its own Pixel or dataset and access token, or turn CAPI off there. Store the Pixel ID and token as environment variables so the live values exist only in production.

Does FunnelGuard catch this?

Could add

Not checked yet: could be added to FunnelGuard.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.