Documentation
Feedback
Guides
API Reference

Guides
Guides

VTEX Ads Core Package Quickstart

Get started with @vtex/ads-core package for fundamental advertising functionality in any JavaScript environment.

The @vtex/ads-core package provides the fundamental advertising functionality for any JavaScript environment. This package is ideal when you're not using React or need maximum flexibility and control.

Installation

Install the package using npm or yarn:


_10
npm install @vtex/ads-core
_10
# or
_10
yarn add @vtex/ads-core

Minimal example

Here's a minimal example to get you started:


_35
import { getRawAds } from "@vtex/ads-core";
_35
_35
// Configure your ad request
_35
const adRequest = {
_35
identity: {
_35
accountName: "your-account-name",
_35
publisherId: "your-publisher-id",
_35
userId: "user-123",
_35
sessionId: "session-456",
_35
channel: "web", // optional: 'web' | 'mobile'
_35
},
_35
search: {
_35
term: "smartphone", // optional search term
_35
selectedFacets: [
_35
// optional filters
_35
{ key: "brand", value: "Acme" },
_35
{ key: "category", value: "Tools" },
_35
],
_35
skuId: "SKU-123", // optional specific product
_35
},
_35
placements: {
_35
search_top_product: {
_35
quantity: 3,
_35
types: ["product"],
_35
},
_35
},
_35
};
_35
_35
// Get raw ads
_35
try {
_35
const rawAds = await getRawAds(adRequest);
_35
console.log("Raw ads:", rawAds.sponsoredProducts);
_35
} catch (error) {
_35
console.error("Failed to fetch ads:", error);
_35
}

Contributors
1
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
1
Photo of the contributor
Was this helpful?
Suggest edits (GitHub)
On this page