Implementing transparent integration for VTEX Ads
Set up transparent integration for Banner and Video ads using the VTEX Ads script and a client-side conversion beacon.
Transparent integration only serves Banner and Video ads.
Transparent integration is a low-friction setup designed to start a VTEX Ads integration on your website or mobile site (msite) in the simplest way possible. Instead of building a full custom API integration upfront, you combine an active catalog integration with a client-side VTEX Ads script and a browser conversion event.
For the broader VTEX Ads integration landscape, see VTEX Ads.
Before you begin
Make sure the following requirements are in place before setting up the transparent integration:
- Catalog integration: You have an active catalog integration following the standard VTEX Ads format. See Synchronizing the catalog with VTEX Ads.
- Publisher ID: You have your
publisher_ididentifier for VTEX Ads, which is required in the conversion event payload. - Session and user parameter origins: You know where your storefront stores
session_idanduser_id(cookies,sessionStorage, orlocalStorage).
1. Install the transparent integration script
Add the following script tag as early as possible inside the <head> tag of your website or mobile site (msite):
_10<script src="https://cdn.newtail.com.br/retail-media/scripts/vtexads-magic-1.0.0.js"></script>
The
vtexads-magic-1.0.0.jsscript applies only to this transparent integration and doesn't replacevtexads-agent.1.0.0.js, which is documented in VTEX Ads Script Agent. For custom API integrations that send browser impression and click events directly, see Ads events notification.
Share session and user parameter origins
For vtexads-magic-1.0.0.js to work properly, you must inform the VTEX Ads team of the origin of two parameters on your storefront:
session_iduser_id
These parameters are usually stored in cookies, sessionStorage, or localStorage.
2. Send the client-side conversion event
Trigger the conversion event on the client side after the order is created, without waiting for payment confirmation.
Use the navigator.sendBeacon interface to send the conversion payload as a JSON Blob (application/json) to https://newtail-media.newtail.com.br/v1/beacon/conversion. Because navigator.sendBeacon sends small amounts of data asynchronously, it transmits conversion analytics before the user navigates away from the page without affecting current page performance or the load time of the next page.
This client-side
navigator.sendBeaconflow is the authoritative conversion path for the transparent integration. Unlike the standard server-side flow in Conversion andPOSTTrack conversions, which sends a server-side request toevents.newtail-media.newtail.com.brwhen an order is closed, this integration sends a browser beacon tohttps://newtail-media.newtail.com.br/v1/beacon/conversionafter order creation without payment confirmation.
_49const data = {_49 "publisher_id": "d4dff0cb-1f21-4a96-9acf-d9426a5ed08c",_49 "user_id": "26119121",_49 "order_id": "1758035060",_49 "channel": "site|msite|app",_49 "created_at": "2025-09-16T15:04:19.794Z",_49 "items": [_49 {_49 "price": 12,_49 "promotional_price": 10,_49 "quantity": 1,_49 "sku": "sku1"_49 },_49 {_49 "price": 15,_49 "promotional_price": 13,_49 "quantity": 1,_49 "sku": "sku2",_49 "seller_id": "seller1"_49 },_49 {_49 "price": 19,_49 "promotional_price": 17,_49 "quantity": 1,_49 "sku": "sku3",_49 "product_id": "prod3"_49 },_49 {_49 "price": 30,_49 "promotional_price": 25,_49 "quantity": 2,_49 "sku": "sku4",_49 "product_id": "prod4",_49 "seller_id": "seller2"_49 }_49 ]_49};_49_49const rawData = JSON.stringify(data);_49const blob = new Blob([rawData], { type: 'application/json' });_49const url = "https://newtail-media.newtail.com.br/v1/beacon/conversion";_49_49const success = navigator.sendBeacon(url, blob);_49_49if (success) {_49 console.log("Beacon request successfully queued!");_49} else {_49 console.error("Failed to queue beacon request.");_49}
Keep the following behavior and payload details in mind when implementing this snippet:
- Channel value: The
channelfield specifies the channel where the order was created (site,msite, orapp). - Item fields: Each entry in
itemsincludesprice,promotional_price,quantity, andsku, and can optionally includeseller_idandproduct_id. - Queue status: The
navigator.sendBeaconmethod returnstrueif the browser queues the request for delivery andfalseotherwise. Becausenavigator.sendBeacondoesn't return aPromise, you can't use.then()or.catch(). Delivery is highly likely, though not guaranteed.
Next steps
- Synchronizing the catalog with VTEX Ads: Set up or verify product and inventory synchronization for your store catalog.
- Ads events notification: Learn how custom integrations send browser impression and click notifications.
- Conversion: Review the server-side conversion
POSTflow used in full API integrations when an order is closed. - VTEX Ads API overview: Explore the complete REST API if you wish to implementa full VTEX Ads integration.