Menu
Guides
API Reference

Guides

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.

4 min read

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_id identifier for VTEX Ads, which is required in the conversion event payload.
  • Session and user parameter origins: You know where your storefront stores session_id and user_id (cookies, sessionStorage, or localStorage).

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.js script applies only to this transparent integration and doesn't replace vtexads-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_id
  • user_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.sendBeacon flow is the authoritative conversion path for the transparent integration. Unlike the standard server-side flow in Conversion and POST Track conversions, which sends a server-side request to events.newtail-media.newtail.com.br when an order is closed, this integration sends a browser beacon to https://newtail-media.newtail.com.br/v1/beacon/conversion after order creation without payment confirmation.


_49
const 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
_49
const rawData = JSON.stringify(data);
_49
const blob = new Blob([rawData], { type: 'application/json' });
_49
const url = "https://newtail-media.newtail.com.br/v1/beacon/conversion";
_49
_49
const success = navigator.sendBeacon(url, blob);
_49
_49
if (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 channel field specifies the channel where the order was created (site, msite, or app).
  • Item fields: Each entry in items includes price, promotional_price, quantity, and sku, and can optionally include seller_id and product_id.
  • Queue status: The navigator.sendBeacon method returns true if the browser queues the request for delivery and false otherwise. Because navigator.sendBeacon doesn't return a Promise, you can't use .then() or .catch(). Delivery is highly likely, though not guaranteed.

Next steps