Menu
Guides
API Reference

Guides

VTEX Ads Stories Package Configuration

Configure the vtex-ads-story-carousel element with its attributes, language and label overrides, CSS variables, and session and user ID rules for Story ads.

7 min read

The <vtex-ads-story-carousel> element of the @vtex/ads-stories package is configured with HTML attributes, a lang attribute for its language, and CSS variables for its look. This guide describes each of them, what the element does while it loads or when something goes wrong, and the rules for the session and user IDs you pass to it.

The element requests the placement's Stories from the VTEX Ads API with @vtex/ads-core and shows them in a carousel. If you haven't installed the package yet, see the VTEX Ads Stories Package Quickstart.

You can try the attributes and CSS variables interactively in the Stories Storybook.

Story ads are off by default. Request enablement for your store through VTEX Support before displaying Stories. For the setup steps, see Before you begin.

Attributes

The table lists the attributes you can set on <vtex-ads-story-carousel>. The highlighted Story is the full-size card. When the carousel shows multiple Stories, the other visible cards are smaller and dimmed.

AttributeRequiredDefaultDescription
publisher-idYesNoneThe publisher the ads are requested for.
session-idYesNoneThe store's session ID. Use the same one sent with the store's other ad events. See Session and user IDs.
placementYesNoneA Story placement name of your choice, for example home_stories. A store can have multiple Story placements, but every Story placement currently returns the same Stories.
user-idNoNoneThe shopper's opaque ID, when known. Never personal data. See Session and user IDs.
account-nameNoNoneThe VTEX account name. It also turns on product hydration from Intelligent Search. Hydration means the element requests the products' current price and availability from the store catalog to show in the product card.
channelNoNonesite or app. Other values are not sent.
timeoutNo2000Time limit for the ad request, in milliseconds.
quantityNo8How many Stories to request, which is the number of carousel positions. A value below 1 or one that isn't a number uses the default.
currencyNoBRLCurrency of the product prices, as an ISO 4217 code, such as BRL or ARS. An invalid code uses the default.
label-add-to-cartNoText in the element's languageThe add to cart button's text. A missing or blank value uses the default text in the element's language. See Language.
label-view-productNoText in the element's languageThe view product button's text. A missing or blank value uses the default text in the element's language.
label-unavailableNoText in the element's languageThe disabled button's text for a product that can't be bought. A missing or blank value uses the default text in the element's language.
label-sold-outNoText in the element's languageThe sold out text, shown with the price and read by screen readers. A missing or blank value uses the default text in the element's language.
inactive-autoplayNoOffWith more than one Story, the visible cards without the highlight also play their video, muted. It's on when the attribute is present without a value or with "true". When it's off, those cards show only their cover.
slide-durationNo5000With more than one Story, how long each one stays highlighted before the next, in milliseconds. 0 turns off the automatic advance. The minimum is 2000 and the maximum is 120000. Other values are raised or capped to them.
hydrationNoNonenone turns off the product request. Any other value is ignored. To set a custom strategy, use the hydration property of the element instead of the attribute.
hydration-timeoutNo5000Time limit for the product request, in milliseconds.

Loading and errors

While the request is pending, and then until the first Story's cover or video loads, whichever comes first (up to 3 seconds), the element shows a skeleton of the carousel. The videos start from the beginning when the skeleton leaves.

The element renders nothing in any of these cases:

  • A required attribute is missing.
  • The request fails or takes longer than timeout.
  • The placement has no Story.

A failed request is logged to the console, except when it took longer than timeout. This lets you tell a failure apart from a placement with no Story.

Changing attributes

The element requests Stories again only when you change publisher-id, session-id, placement, user-id, account-name, channel, quantity, or the hydration strategy (hydration).

A new timeout applies to the next request. A new slide-duration starts the highlighted Story's time over.

Language

The element reads lang from the carousel itself or the closest ancestor that sets it, usually <html>. To set the language for the carousel alone, use <vtex-ads-story-carousel lang="es-AR">. The language controls price formatting and the text shoppers see or hear.

  • Button labels, such as Add to cart.
  • The Sold out label.
  • Short notices shown over the video.
  • Accessible names read by screen readers.

The texts come in Portuguese, Spanish, and English, and the element picks them by the language alone. For example, es-AR and es-MX both get Spanish. Without a lang attribute, or with another language, the texts are in Portuguese and the prices use pt-BR.

This guide quotes the English texts, such as Add to cart and Sold out. A page without a lang attribute shows them in Portuguese.

The label-add-to-cart, label-view-product, label-unavailable, and label-sold-out attributes replace those texts in any language:


_10
<vtex-ads-story-carousel
_10
lang="es-AR"
_10
label-add-to-cart="Comprar"
_10
label-view-product="Ver detalles"
_10
label-unavailable="No disponible"
_10
label-sold-out="Agotado"
_10
...
_10
></vtex-ads-story-carousel>

The call to action's text comes from the campaign, so you can't change it with an attribute.

Customization

Set the element's look with CSS variables on the element or on any ancestor:


_10
vtex-ads-story-carousel {
_10
--vtex-ads-story-font-family: "Inter", sans-serif;
_10
--vtex-ads-story-color-text: #1f1f1f;
_10
--vtex-ads-story-color-muted: #6b6b6b;
_10
--vtex-ads-story-color-surface: #fff;
_10
--vtex-ads-story-color-accent: #1b75a8;
_10
--vtex-ads-story-color-accent-contrast: #fff;
_10
--vtex-ads-story-radius: 20px;
_10
}

In the table, the panel is the product panel that opens over a Story with the product's details and buttons. The pills are the rounded labels over a Story for its product and its call to action.

VariableDefaultUsed for
--vtex-ads-story-font-familyInheritedAll text.
--vtex-ads-story-color-textInherited (#242424 in the panel)All text off the video, such as the open product panel's.
--vtex-ads-story-color-muted#6b6b6bThe panel's "from" price and its disabled add to cart button.
--vtex-ads-story-color-surface#fff (#fafafa behind the card)The open product panel, the view product button, and the background behind a single Story.
--vtex-ads-story-color-accent#1b75a8The product panel's buttons.
--vtex-ads-story-color-accent-contrast#fffText on the add to cart button.
--vtex-ads-story-radius20px on the cards, 16px on the pills, fully round on the buttonsThe corner radius of the cards, the pills, the panel's buttons, and other elements listed below the table.

The --vtex-ads-story-radius variable also sets the corners of these elements:

  • The background behind a single Story.
  • The covers beside the expanded video.
  • The player's dim overlay.
  • The product thumbnail, whose radius is the pill's radius minus 8px.
  • The quantity stepper in the panel.
  • The video's retry button.

A value of 0px makes all of them square. The round icon buttons on the video stay round.

Text over the video stays white. It sits on the video, not on a store color, so no variable changes it.

Session and user IDs

The element sends VTEX Ads two IDs so it can tell one shopper from another: the session ID and, optionally, the user ID. Neither should be personal data. VTEX Ads doesn't need to know who the shopper is.

Where the IDs go

  • The ad request: session_id and user_id, in the body of every request to the ad API.
  • The events: session_id and user_id, in the body of every impression, view, and click event that the element sends.
  • The page: the session-id and user-id attributes are in the page's HTML, where any script on the page can read them.

Session ID

The session-id attribute is the store's session: a random, opaque value that changes when the session does. Use the same one the store sends with its other ad events. Don't build it from personal data.

User ID

The user-id attribute is optional. When set, it is the shopper's ID in the store's platform, the same in every channel, so that VTEX Ads can tell the same shopper apart across sessions.

Use an opaque ID, such as the customer's internal ID. Never send any of the following:

  • An email address, a phone number, or a name.
  • A document number, such as a CPF or CNPJ (the Brazilian tax ID numbers for individuals and companies).
  • A hash of any of these. Anyone who has the same data can match a hash of an email or a document back to the person.

Without an ID like that, leave user-id out. The ads and the events work with the session ID alone.

Other fields

The same applies to the rest of the request, such as search terms, tags, and any custom field. They carry what the shopper is browsing, not who they are.

A custom product hydration strategy also receives the shopper's identity. It shouldn't send it anywhere else.

Next steps