Full tracking (URL parameters, click, sale linked to the ad and purchase in Meta)
Make sure every sale reaches Espectro with the campaign, ad set and ad the customer came from, goes to Meta from the server without being counted twice and, if you want, to your own systems. This tutorial brings together everything that needs to be right, from the ad to the report.
On this page
Who does it
The media buyer (or the account owner) in the ads; the account owner in Espectro (products with a token, Postback). The team can see the screens and the numbers.
Before you start
- Integrations working (Integrations).
- Espectro script on the product page, with
data-contaanddata-pixel(Install the script). - Product with Pixel, token and rule (Products and pixels).
- Ad account connected (connect the ad account), so spend, budget and status come from Meta.
URL parameters in the ads
What it is for: making Meta send, on every click, the name and number of the campaign, ad set and ad. This text, pasted into the URL parameters field of each Meta ad, is what makes the sale arrive with the campaign, ad set and ad. Without it, the sale shows up as "Direct".
The URL parameters screen (Settings group) shows the ready-made text with Copy, the 3 steps for where to paste it and, in What each macro becomes, an explanation of each part and the Copy UTM part only button.
Step by step:
- In Settings > URL parameters (or through the button on the Meta Ads screen), click Copy. The text is the same for all ads:
utm_source=FB&utm_campaign={{campaign.name}}|{{campaign.id}}&utm_medium={{adset.name}}|{{adset.id}}&utm_content={{ad.name}}|{{ad.id}}&utm_term={{placement}}&esp_c={{campaign.id}}&esp_s={{adset.id}}&esp_a={{ad.id}}&esp_p={{placement}}&esp_ss={{site_source_name}} - In Ads Manager, open the ad (or select several and click Edit).
- Scroll down to Tracking and paste it into URL parameters. Do not paste it into the website field (Website URL).
- Click Publish.

What each part is: the first part (utm_...) is the same as UTMify's, so it works for both at once while they run together. The second (esp_...) carries the bare numbers, so Espectro can link the sale to the ad even if the name has odd characters or gets changed. The UTM part alone also works (Copy UTM part only button): Espectro reads the number from "name|number".
What usually goes wrong:
- The campaign shows up with the text
{{campaign.name}}: it was pasted into the website field. - An old ad without the text keeps running, but its sales have no campaign until you paste the text and publish.
The path, piece by piece
| Step | What happens | What needs to be set up | Where to check |
|---|---|---|---|
| 1. Ad | The click carries the campaign, ad set and ad parameters | URL parameters on every ad (above) | Address of the page opened by the ad |
| 2. Sales page | espectro.js records the arrival (the "click", with an esp... id), keeps the UTMs for 90 days and fires PageView and ViewContent | Script in the head with data-conta and data-pixel (Install the script) | Events, page funnel |
| 3. Buy button | The checkout link gets the UTMs, esp_ck and sck; the click counts as a checkout start | data-checkout-hosts or data-checkout on the button | Checkout address; Meta Ads, Checkout starts column |
| 4. Checkout | The customer generates the PIX; the checkout notifies Espectro (order created, PIX generated, paid, refused) | The store's integration (Integrations) and, in Pay, the Espectro destination | Integrations, Events received; Orders, Webhooks sent |
| 5. Espectro | Links the sale to the exact click (or to the ad number in the UTMs) and adds it to the numbers | Nothing else | Sales, Campaign and ad column; sale screen, Matched by |
| 6. Meta (server) | Sends the page events (same event_id as the browser), AddPaymentInfo when the PIX is generated (server only) and Purchase when it is paid (in Espectro Pay, with the same event_id as the PIX page) | Product with Pixel, token and rule in Products and pixels (Products and pixels) | Events; Pixel column in Sales; sale screen |
| 7. Spend | Reads Meta's spend per day and adds it to the profit | Ad account connected | Overview and Meta Ads |
| 8. Your systems | The Postback notifies your systems | Destination in Postback | Postback, Latest deliveries |
The click, in detail
The script records on the Espectro server every arrival on the page (the "click"): its own id (esp + letters and numbers), the UTMs, the ad IDs, the fbclid, the fbc and the fbp, the page, where the visitor came from, the IP and the browser. It works even if the browser blocks the Meta Pixel. The click id goes in the checkout link in esp_ck and in sck (or src, when sck already has another value). Zedy keeps sck and sends it back in the webhook: that way the sale is linked to the exact click. Espectro Pay receives it directly. The click on the Buy button counts as a checkout start; the same visitor repeating it within 30 min does not count again.
How the sale is linked to the ad
In order of precision:
- exact click (Espectro id): the sale came back with the click code (
esp_ckorsck) and the click had a campaign. This is the best case. The sale screen also shows the same visitor's first click, when it is different. - ad ID in UTMs: the sale brought the campaign or ad number.
- name in UTMs: only the name came (an old ad without the numbers). Renaming the campaign gets in the way.
- Nothing: the sale shows up as Direct.
Where to see the result: on the sale screen, in Matched by (the sale screen), and in the campaigns, ad sets and ads table in Meta Ads, where each creative shows up with sales, spend and profit.
So the purchase is not counted twice
- For the page events and the Espectro Pay purchase, the browser and the server send the same event with the same event_id: Meta merges the two. On Zedy and Other platform, the purchase goes out only from the server: if the platform also fires the same Pixel, use Observe only on the product (Zedy integration).
- While UTMify (or the checkout platform) still sends the purchase to the same Pixel:
- use the script with
data-modo="observar"; - keep the products on Automatic (follows the page script) or Observe only (UTMify still sends);
- check in Events the Purchases observed number and, in the funnel, the InitiateCheckout Observed: that is what Espectro would send.
- use the script with
- When the other tool stops:
- replace the script with the line without
data-modo; - if you want to force it, change the product to Always send;
- check in Events that the purchases change to Sent.
- replace the script with the line without
- Espectro Pay sales that the other tool does not see can be on Always send from the start (the server purchase goes out; the page events in observe mode still do not go out).
- Remove the old Pixel code from the page once
espectro.jsstarts firing the same Pixel.
What each sending mode does: sending mode. Which events go out and when: Events.
Full test
- Open the sales page with
?utm_source=FB&utm_campaign=teste|123456. - Click Buy and check for
esp_ck=esp...andsck=esp...in the checkout address. - With the Test code filled in on the product (test), generate a test PIX (from R$6.00) and pay it. Then delete the code.
- Check: Orders (Webhooks sent with HTTP 200), Sales (campaign "teste"; Matched by: exact click), Events (Purchase Sent or Observed) and Meta's Events Manager.
How to know it worked
- In Sales, the Campaign and ad column shows the name (not "Direct"); the sale screen says "Matched by: exact click".
- In Meta Ads, the campaigns show up with sales, spend and profit, and the badge says All sales tracked.
- In Events, the funnel shows InitiateCheckout saved and with an ad click.
Common problems and fixes
| Problem | Fix |
|---|---|
| Sales as "Direct". | Ad without the URL parameters, page without the script (Install the script), a buy button that does not go through the script, or the person came in directly (in that case "Direct" is correct). |
The campaign shows up with the text {{campaign.name}}. | The text was pasted into the website field, not into URL parameters. |
| The sale arrives without a click ("No click recorded"). | data-conta is missing from the script, the buy link is not in data-checkout-hosts, or the checkout does not send back sck (Install the script). |
| Checkout starts at zero with pending sales. | The buy button does not point to an address in data-checkout-hosts (or does not have data-checkout). |
| Spend N/A in the table. | Connect the ad account. |
| The purchase did not go to Meta and shows "Observed". | Observe mode (script or product). Change the product to Always send when UTMify stops sending. |
| Meta counts the purchase twice. | Another tool sends to the same Pixel, an old Pixel on the page, Zedy with the same Pixel, or a custom-built checkout calling espectro.compra with the Other platform integration without the Purchase id mapped. Use observe mode (above), remove the old code, use Observe only on the product, and map the Purchase id or do not call espectro.compra (on the checkout). |
| Postback failing. | Check the address (https) and see the error in Latest deliveries (Postback). |