Skip to content
Espectro Soluções

Espectro: install the script on the sales page and on the checkout

Put the Espectro script (espectro.js) in the head of the sales page to record every visit that comes from an ad, remember which ad the person came from (for 90 days, in their browser), pass that on to the checkout when they click Buy, count the checkout start and, if you want, fire the product's Pixel. It works even when the browser blocks the Meta Pixel. If Espectro is down, the page and the checkout keep working.

On this page
  1. Who does it
  2. Before you start
  3. What the script does, in plain words
  4. What happens when the page opens
  5. Step by step
  6. Part A. Copy the script line
  7. Part B. Adjust the line for your page
  8. Part C. Paste it in the page head
  9. Part D. Mark the Buy button
  10. Each attribute
  11. Part E. On the checkout
  12. Part F. The complete lines, from the page to the PIX
  13. How to know it worked
  14. Common problems and fixes

Who does it

The account owner, or whoever takes care of the store's website.

Before you start

  • Access to edit the sales page (site builder, WordPress, landing page platform or HTML).
  • The product's checkout address (Checkout products), for example seguro.sualoja.com.br or pay.espectrosolucoes.com.br.
  • The Meta pixel ID of the product on that page (Products and pixels). One Pixel per product.

What the script does, in plain words

  • Every arrival on the page becomes a click recorded in Espectro, with its own code. This works even when the browser blocks the Meta Pixel.
  • When the person arrives from an ad, the page address carries the UTMs (which campaign, ad set and ad they came from). The script keeps this for 90 days in their browser.
  • When they click Buy, the script adds this information and the click code to the checkout link. The checkout sends the code back with the sale, so the sale reaches Espectro linked to the right ad.
  • The click on the checkout link counts as a checkout start.
  • If the line has the Pixel ID, the script also fires the Meta Pixel in the browser: page visit (PageView), product view (ViewContent, after 8 seconds or when the person scrolls the page) and checkout start (InitiateCheckout).
  • The script does not delete or replace what another tracking tool has already added to the link: both can run together.
  • The same line also records how the person moves through the page (recording, click map and scroll map). There is no other script for it: recording starts when it is on in Landing page > Recordings and the page is registered in Landing page > Monitored pages (Session recordings and Landing page). The Espectro Pay checkout is recorded with no registration.

What happens when the page opens

  1. The script keeps the UTMs and the ad click (fbclid) in a store cookie for 90 days. Someone who comes back another day stays tied to the ad.
  2. It records the visit in Espectro and, with data-pixel, fires the product pixel.
  3. It asks Espectro whether the page is in Monitored pages. If it is, and the visit falls within the chosen percentage, recording starts.
  4. On the Buy click, it counts the checkout start and takes the person to the checkout with the UTMs and the click code in the link.
  5. In Espectro Pay, the purchase goes to Meta through the Conversions API with the same code as the browser, so Meta does not count it twice.

Step by step

Part A. Copy the script line

  1. In Espectro, in the Settings group, click Integrations (incoming webhooks).
  2. Scroll down to the Page script card and click Copy on the first line. It already comes with your account code, similar to this: <script src="https://app.espectrosolucoes.com.br/espectro.js" data-conta="minhaloja" data-checkout-hosts="pay.espectrosolucoes.com.br" async></script>
  3. Right below there is a second line, with data-modo="observar". Use it only if another tool (for example UTMify, or the checkout platform itself) still sends the purchase to the same Pixel. See Part B.
Page script card with the two lines and the list of attributes
Page script card with the two lines and the list of attributes

Part B. Adjust the line for your page

  1. The line already comes with pay.espectrosolucoes.com.br, the Espectro Pay checkout address. If you sell through Espectro Pay, leave it as is. If you sell through another checkout, replace it with that checkout's domain (without https://); if there are several, separate them with commas.
  2. Add data-pixel with the Pixel of the product on that page: <script src="https://app.espectrosolucoes.com.br/espectro.js" data-conta="minhaloja" data-pixel="123456789012345" data-checkout-hosts="pay.espectrosolucoes.com.br" async></script> Without data-pixel, the script records the clicks and passes on the UTMs, but does not fire a Pixel in the browser. Each product page has its own line. From one product to another, only the data-pixel number changes.
  3. If another tool still sends the purchase to the same Pixel, use the card's second line, with data-modo="observar". In this mode the script does not fire the Pixel in the browser (even with data-pixel) and puts products whose Conversions API sending is set to Automatic into observe-only (Products and pixels). When the other tool stops sending the purchase, switch to the line without data-modo (Full tracking).

Part C. Paste it in the page head

  1. Open the sales page editor.
  2. Look for the place for header code. The name changes on each platform: "header code", "head", "custom scripts", "tracking code" or "custom HTML". In page builders it is usually in the page or site settings; in WordPress, in a plugin for inserting header code or in the theme itself. If you cannot find it, search your platform's help for "add code to the head".
  3. Paste the line inside the page's <head> and publish.
  4. If the page already had the Meta Pixel code pasted by hand for the same Pixel, remove the old one.

Part D. Mark the Buy button

  1. The Buy button must point to the checkout link (Checkout products).
  2. These links get the UTMs and the click code automatically: links to the addresses in data-checkout-hosts (and their subdomains), links with "checkout" in the domain, and links whose domain starts with pay. (the Espectro Pay case).
  3. For any other checkout link, add the data-checkout attribute to the button link: <a href="LINK_DO_CHECKOUT" data-checkout>Comprar</a>

Each attribute

AttributeWhat it is for
data-contaYour account code. Every arrival becomes a click recorded in Espectro, with its own id that goes in the checkout link (esp_ck and sck, or src) and comes back in the sale's webhook.
data-checkout-hostsThe checkout addresses. Links to them get the UTMs and the click id, and a click on them counts as a checkout start.
data-pixelThe product's Pixel. Fires PageView, ViewContent (8 seconds or scroll) and InitiateCheckout in the browser and, if the Pixel is set up on a product with a token in Products and pixels, also from the server, with the same event_id. Without it, the script records and passes on the UTMs, but does not fire a Pixel.
data-modo="observar"Does not fire the Pixel in the browser and puts the Conversions API of products set to Automatic into observe-only.
data-gravar="nao"This page is never recorded, even with session recordings turned on.
data-evento="produto"Fires ViewContent as soon as the page opens.
data-evento="checkout"For the checkout itself: fires InitiateCheckout when it opens, except when the click on the sales page already sent InitiateCheckout through the same Pixel less than 30 min earlier.
data-evento="pagamento"For the payment page: does not send ViewContent (PageView still goes); the purchase goes out with espectro.compra.
data-produto and data-valorThe product id and the amount in reais (with a dot, for example 97.90), sent along with the events.
data-checkoutGoes on the button link (the <a href> tag) or on the form, not on the script or on a standalone <button>. Marks a checkout link that is not in data-checkout-hosts. Links with "checkout" in the domain, links that start with pay. or links to subdomains of the data-checkout-hosts addresses already count.

How the script marks the links: when the page loads, again at 3 and at 10 seconds, and on click. Whatever is already in the link (for example, UTMify's UTMs) is not replaced. A form submitted to the checkout also counts as a checkout start. The last click wins: a new ad click replaces the previous one; a visit with no parameters keeps the stored one. With a wrong data-conta, nothing is recorded, but the Pixel fires. For a custom-built checkout there are also espectro.dados() and espectro.decorar(url).

Part E. On the checkout

  • Espectro Pay: you do not need to do anything on the checkout, as long as the Pay product has the Pixel in the Meta pixel card (Checkout products). The checkout already loads the script with the product's Pixel and marks the purchase on the PIX page with the same code the server sends (Meta does not count it twice). The purchase in the browser is only marked if the PIX page is open when the payment is confirmed; the server one always goes out. The Pay checkout has no observe mode.
  • Zedy and others: only what the platform lets you install. The browser Pixel stays with the platform; Espectro sends the purchase from the server, with a different event_id. If the platform fires the same Pixel, use Observe only on the product (Zedy integration).
  • Custom-built checkout (made by a developer): paste the line in the checkout head with data-pixel and data-evento="checkout". If the sales come through the Other platform integration and the checkout calls espectro.compra (for example espectro.compra({ valor, eventId, produtoId, nome }) when the payment is confirmed), send the same eventId in the webhook and point that field to Purchase id, in Map fields (incoming webhook): Meta merges the two and counts a single sale. Without that field mapped, do not call espectro.compra: the purchase goes only from the server. The full example is in the Page script card.

Part F. The complete lines, from the page to the PIX

It is always the same script, espectro.js. Only what is written in it changes in each place. Example with the account minhaloja, the pixel 123456789012345 and the product kit-exemplo at R$ 97.90:

  1. On the sales page, in the head. It is the only line anyone pastes: <script src="https://app.espectrosolucoes.com.br/espectro.js" data-conta="minhaloja" data-pixel="123456789012345" data-checkout-hosts="pay.espectrosolucoes.com.br" async></script> It stands alone in the head: no UTMify, no script from another checkout and no hand-pasted Pixel code (espectro.js already loads the Pixel).
  2. On the Espectro Pay checkout: nobody pastes anything. Pay adds it by itself, with the product's Pixel: <script src="https://app.espectrosolucoes.com.br/espectro.js" async data-conta="minhaloja" data-evento="checkout" data-pixel="123456789012345" data-produto="kit-exemplo" data-valor="97.90"></script> data-evento="checkout" fires the checkout start, except when the click on the sales page already sent the same event less than 30 minutes earlier (it does not count twice).
  3. On the PIX page: also automatic: <script src="https://app.espectrosolucoes.com.br/espectro.js" async data-conta="minhaloja" data-evento="pagamento" data-pixel="123456789012345" data-produto="kit-exemplo"></script> When the PIX is paid, it marks the purchase in the browser with the same code the server sends through the Conversions API, so Meta counts it once.
WhereWho adds itWhat changes from one product to another
Sales pageYou, one line in the headOnly data-pixel
CheckoutEspectro Pay, by itselfComes from the Pixel set on the Pay product
PIX pageEspectro Pay, by itselfComes from the same Pixel

The same Pixel at every step lets Meta see the whole path: visit, checkout start and purchase.

How to know it worked

  1. Open the page with ?utm_source=FB&utm_campaign=teste at the end of the address.
  2. Hover over the Buy button (or click it) and check that the link now has utm_source=FB&utm_campaign=teste and an esp_ck= at the end.
  3. For the Pixel (with data-pixel and outside observe mode), use the test events area in Events Manager or the Meta Pixel Helper extension.
  4. In Events (Read your numbers), the funnel shows PageView and InitiateCheckout received.

Common problems and fixes

ProblemWhy it happensFix
The UTMs do not reach the checkout.The line is not on the published page, or the link was not recognized.Check that the line is in the head of the published page. Check data-checkout-hosts or add data-checkout to the button.
The Pixel does not fire.data-pixel is missing, the line is in observe mode, or there is an ad blocker.Check that data-pixel has only numbers and is that product's Pixel, and that the line does not have data-modo="observar". Test without an ad blocker.
Two Pixels firing.The old code is still on the page.Remove the old code for the same Pixel, or use observe mode while the other tool still fires.
Wrong Pixel.The page uses another product's Pixel.Each page needs its own product's Pixel. Do not use the same Pixel on different products (Products and pixels).
The sale arrives with no identified campaign.The person came in without UTMs, or the ad does not have the URL parameters.Paste the URL parameters into the ads.
"No click recorded" on the sale.data-conta is missing, the link is not in data-checkout-hosts, or the checkout does not send back sck.Check the line and the button (Parts B and D).