Menu
Guides
API Reference

Guides

Integrating Story ads

Call the VTEX Ads API to build your own Story carousel or native app, show the Story videos, and send impression, view, and click events.

10 min read

Story ads are a video ad format. Each Story is a 9:16 video that the shopper watches in a carousel and can follow to a product or to the advertiser's link. If your store builds its own carousel or a native app, you call the VTEX Ads API directly. Your integration then shows the Stories and sends their events, as this guide describes.

The <vtex-ads-story-carousel> element of the @vtex/ads-stories package does everything in this guide for your store, so it's the reference implementation. When in doubt, do what the element does. If you don't need a custom integration, use the element instead. See the VTEX Ads Stories Package Quickstart.

Before you begin

Story ads are off by default. Before your store can show them, open a ticket with VTEX Support to request Story enablement for your store. For a network, it's enabled once for the whole network.

After Story is enabled for your store, go to the VTEX Ads platform and complete these steps:

  1. In Settings > Ad types, select Story and save.
  2. In Settings > Advertisers, add Story to the ad types of each advertiser that can run Story campaigns.

After this setup, advertisers can create Story campaigns, which run once the store approves them.

You can build your integration before the store is enabled. Until the placement has eligible Stories, the API returns an empty list.

You also need your VTEX Ads publisher ID, a Story placement name of your choice (for example, home_stories), and the session ID your storefront already uses for VTEX Ads events. Registering the placement on the VTEX Ads platform is optional and lets you track performance by placement.

1. Request the Stories

To request the Stories of a placement, send a POST request to the Get ads endpoint, which is the same endpoint described in Retrieving ads. Pass the publisher ID in the path and your Story placement as the key of placements, with types set to ["story"].


_10
POST https://newtail-media.newtail.com.br/v1/rma/{publisher-id}
_10
Content-Type: application/json


_10
{
_10
"session_id": "the-store-session-id",
_10
"user_id": "the-shopper-opaque-id",
_10
"context": "home",
_10
"channel": "site",
_10
"placements": {
_10
"home_stories": { "types": ["story"], "quantity": 8 }
_10
}
_10
}

For Story ads, keep the following in mind:

  • session_id: The store's session ID. Send the same one in every event.
  • user_id: The shopper's opaque ID. It's optional for Story ads.
  • context: The page type, which is home, search, category, brand_page, or product_page. The <vtex-ads-story-carousel> element sends home.
  • channel: site or app.
  • placements.{placement}: Any Story placement name of your choice. A store can have multiple Story placements, but every Story placement currently returns the same Stories.
  • placements.{placement}.types: ["story"].
  • placements.{placement}.quantity: How many Stories to return, which are the carousel positions. One campaign is one Story, so the API returns fewer Stories when fewer campaigns are eligible.

For the full request schema, see POST Get ads in the API Reference.

The session_id and user_id must not be personal data. Use an opaque ID, such as the customer's internal ID, for user_id. Never send an email address, a phone number, a name, a document number, or a hash of any of these, because anyone with the same data can match a hash back to the person. Without an opaque ID, leave user_id out. The ads and the events work with session_id alone. For the rules that apply to both IDs, see Session and user IDs.

For a direct API integration, set a request timeout of 500–600 ms so a slow ad request doesn't delay the storefront. See Request best practices. The <vtex-ads-story-carousel> element uses a default timeout of 2 seconds.

2. Read the response

The placement's key holds one item per Story, in carousel order. Other keys, such as request_id, identify the request.


_30
{
_30
"home_stories": [
_30
{
_30
"type": "story",
_30
"ad_id": "8f2c…",
_30
"campaign_id": "51ab…",
_30
"seller_id": "1",
_30
"position": 0,
_30
"campaign_name": "Spring sale",
_30
"asset_type": "video",
_30
"media_url": "https://cdn.newtail.com.br/retail_media/ads-video/story/…/2026/10/16/….mp4",
_30
"poster_url": "https://cdn.newtail.com.br/retail_media/ads-video/story/…/2026/10/16/….jpg",
_30
"duration_seconds": 14,
_30
"call_to_action": null,
_30
"destination_url": "https://www.mystore.com/sneaker/p",
_30
"product": {
_30
"product_sku": "1234",
_30
"seller_id": "1",
_30
"product_name": "Sneaker",
_30
"image_url": "https://mystore.vteximg.com.br/arquivos/ids/1234/sneaker.jpg",
_30
"url": "https://www.mystore.com/sneaker/p",
_30
"product_metadata": { "price": 299.9, "promotional_price": 249.9 }
_30
},
_30
"impression_url": "https://events.newtail-media.newtail.com.br/v1/beacon/impression/8f2c…",
_30
"view_url": "https://events.newtail-media.newtail.com.br/v1/beacon/view/8f2c…",
_30
"click_url": "https://events.newtail-media.newtail.com.br/v1/beacon/click/8f2c…"
_30
}
_30
],
_30
"request_id": "…"
_30
}

The following table summarizes the fields of a Story item. For the full response schema, see POST Get ads in the API Reference.

FieldDescription
typeAlways story.
ad_id, campaign_id, campaign_nameThe ad and its campaign, for diagnosis. One campaign has one Story.
seller_idThe ad's seller, when there is one.
positionThe Story's place in the carousel, starting from 0.
asset_typeAlways video.
media_urlThe video, which is a 9:16 MP4 (1080 × 1920, H.264, up to 60 seconds) with or without sound.
poster_urlThe cover, which is a 1080 × 1920 JPG shown until the video plays.
duration_secondsThe video's length, in whole seconds.
destination_urlWhere the Story leads, which is the product page or the advertiser's link.
productThe featured product, or null when the destination is a link. See Handle the destination.
product.product_sku, product.seller_idThe SKU and its seller, for the store's cart. seller_id can be missing.
product.product_name, product.image_urlThe product's name and image, from the store's catalog.
product.urlThe product page URL from the catalog. Use destination_url for the link the shopper follows from the Story.
product.product_metadataWhat the catalog indexed, which can be empty. When present, price is the regular price and promotional_price is the sale price. A promotional_price of 0 or a missing one means no sale price.
call_to_actionThe call-to-action text set in the campaign. It's set only with a link destination. Otherwise, it's null.
impression_url, view_url, click_urlWhere to send each event. See Send the events.

If the placement returns an empty list, the request fails, or the request times out, skip rendering the Story carousel. Your store can use that space for other content.

3. Handle the destination

A Story leads to a product or to a link:

  • Product: product is set and destination_url is the product page. Show the product with an add-to-cart control, which your store handles, and a link to destination_url.
  • Link: product is null and destination_url is the advertiser's link. Show a call to action with the call_to_action text. When the text is null, the <vtex-ads-story-carousel> element shows no call to action.

For how the element presents each destination, see Product destinations and Call-to-action destinations.

Follow only safe URLs

Follow a destination_url only when it's one of the following:

  • An absolute http or https URL.
  • A path on your store, such as /sneaker/p.

Ignore anything else, including paths that could lead to another host, such as //host and /\host. This is what the element does. See Destination URL safety.

Get the current price and availability

The price in product_metadata is the one indexed with the campaign, so it can be stale or missing. VTEX stores can read the current price and availability from Intelligent Search by product_sku, as the element does. For details, see VTEX Ads Stories Package Product Hydration.

4. Play the media

Follow these rules to play the Story video:

  • Play media_url inline, muted, and looping on the cards, with poster_url as its cover. Browsers only autoplay muted video.
  • Turn the sound on only when the shopper asks for it, for example when they open the Story.
  • When a link opens the destination in a new tab, pause the video, or mute it if it keeps playing.

For how the element plays Stories, see Highlight and video playback.

If your store has a Content Security Policy, allow the hosts that serve the media and the other hosts the integration reaches. See VTEX Ads Stories Package Content Security Policy.

5. Send the events

Send each Story's impression, view, and click to its impression_url, view_url, and click_url from the response, exactly as they came. These URLs carry the ad's data and a signature, so don't build or change them. Send each event at most once per Story and session, when the Story rules in the next section are met.

For the endpoints that receive the events, see POST Track ad impressions, POST Track ad views, and POST Track ad clicks in the API Reference.

Story rules for impressions, views, and clicks

The impression and view rules in this section apply to Story ads only. They differ from the rules for other ad formats, which are described in the Impressions and Views guides. For the other formats, the POST Track ad views endpoint describes a view as the ad occupying at least 50% of the viewport for at least 1 second. Those rules continue to apply to the other formats.

For details on how <vtex-ads-story-carousel> applies these rules, see Ad events.

  • Impression: Send a Story's impression when at least 30% of the Story's card is on screen. Only the Stories that the shopper can see send an impression, so rendering the carousel doesn't send one for every Story. A card that is scrolled out of the carousel or is below the fold sends its impression only when it comes into view.
  • View: Send a Story's view when the video of a card, or of the open player, plays for 2 continuous seconds while at least 50% of the video is on screen and the page is visible. A card that shows only its cover and a paused video don't count as a view.
  • Click: Send a Story's click on the first touch on a card, including its product, call to action, and sound button. When your integration has a player, a first touch on the player's video also counts, including its play and sound buttons, product, and call to action. The previous and next buttons and the buttons that close or expand the player don't count as a click.

In browsers without IntersectionObserver, the element can't tell what is on screen. It sends the impression of every card shown and doesn't send views.

Send the request

Each event is a POST request with a JSON body that contains session_id and, when you have one, user_id. Leave out user_id when there is none. In the following example, sessionId and userId stand for your store's own values:


_10
navigator.sendBeacon(
_10
story.impression_url,
_10
new Blob([JSON.stringify({ session_id: sessionId, user_id: userId })], {
_10
type: "text/plain;charset=utf-8",
_10
}),
_10
);

sendBeacon keeps the event when the shopper leaves the page, and the text/plain type needs no CORS preflight. A native app sends the same POST request with its HTTP client.

Deduplication and conversions

For Story ads, the VTEX Ads API deduplicates each event type per session and ad. It ignores a repeat of the same impression or view within 5 minutes and a repeat click within 1 hour. Your integration must still send each event when its rule is met.

Conversions aren't Story events. They keep coming from your store's VTEX Ads conversion integration. See Conversion.

To learn how VTEX Ads uses session_id and user_id in ad events, see Understanding ads events.

Checklist

Before you go live, confirm the following:

  • The ad request has the Story placement, types: ["story"], the session ID, and a time limit.
  • An empty list, an error, or a timeout leaves the space to your store.
  • Each card shows poster_url and then plays media_url muted and inline.
  • A product destination shows the product, an add-to-cart control, and a link to destination_url. A link destination shows the call to action.
  • destination_url is followed only when it's an http(s) URL or a store path.
  • Impression, view, and click go to their URLs as they came, once per Story and session, with session_id.
  • user_id is an opaque ID, or it's left out.
  • The Content Security Policy allows the ad API, the event host, and the media hosts.

Next steps