@vtex/ads-stories
v0.10.0
Published
VTEX Ads Stories web component
Maintainers
Keywords
Readme
@vtex/ads-stories
VTEX Ads Stories web component. Framework-agnostic: works on any HTML5 page, including VTEX IO, FastStore and non-VTEX storefronts.
Work in progress. Currently requests the placement's Stories from the ad API, shows them in a carousel, whose cards open in a player at the bottom right, sends their impression, view and click events, and tells the store when a product is added to or removed from the cart.
npm
npm install @vtex/ads-storiesRegister the element once, on the client:
import { defineVtexAdsStoryCarousel } from "@vtex/ads-stories";
defineVtexAdsStoryCarousel();<vtex-ads-story-carousel
publisher-id="your-publisher-id"
session-id="the-store-session-id"
placement="home_stories"
></vtex-ads-story-carousel>CDN
The same build is available as a standalone script from
unpkg and jsDelivr. It
registers <vtex-ads-story-carousel> when it loads, so no JavaScript is
needed in the page. Always pin an exact version: replace <version> below
with a version published on
npm.
<script
src="https://unpkg.com/@vtex/ads-stories@<version>"
integrity="sha384-<hash>"
crossorigin="anonymous"
></script>
<vtex-ads-story-carousel
publisher-id="your-publisher-id"
session-id="the-store-session-id"
placement="home_stories"
></vtex-ads-story-carousel>Documentation
The full guide is on the VTEX Ads JS SDK documentation:
- Quickstart: npm and CDN (integrity hash, Content-Security-Policy), server-side rendering, TypeScript and React.
- Configuration: attributes, language and labels, CSS variables.
- Layout and player: the carousel, the product and its cart stepper, the call to action, the player and video errors.
- Product hydration: where prices and availability come from, and custom strategies.
- Events: the add and remove from cart events for the store, and the ad events the element sends.
Contributing
To run the element locally or contribute a change, see CONTRIBUTING.md.
