@ff0000-ad-tech/ad-velvet
v4.1.1
Published
[](https://www.npmjs.com/package/@ff0000-ad-tech%2Fad-velvet) [.


Client & Locale
Client & Locale slugs are always required.
Segment
Segments will allow you to rotate Ad Data on a schedule.
Ad Data
If you wish to target a specific Ad Data for your creative, navigate instead to CAMPAIGN > LOCALE > AD DATA tab. The Slugs object will have addata rather than segment.
This will have the effect of "hard-coding" the ad to the selected Ad Data.
Listening for Events
FAIL - if the load of the data fails
STATIC - if the ad_rotation in the segment json is set as USE_STATIC rather than a number
INIT - when the data is loaded and ready to be consumed
JSON Feeds & Getting Data
Data is passed to the ad in the form of a JSON feed. Once it's loaded, you can access it with the following syntax:
Velvet.get('json-key')For more detail see the Examples below.
Adding Date Settings
The second argument of Velvet.init(arg1, arg2) is the dateSettings object.
var dateSettings = {
dateOverride: ['2017-06-11 09:30:01', 'local'],
language: 'spanish'
}It is optional and it does two things:
- Change the ad’s understanding of what “now” is. For testing, you can easily set the “now” time to the future or past to update the state of the ad.
- Set the date-related messaging to another language. Velvet Enabler natively supports English and Spanish. There are ways to add other languages, which can be found in the docs.
Examples
Setup with Vanilla Javascript
<script id="velvet" src="../dist/velvet-enabler.js"></script>
<script type="text/javascript">
var slugs = {
client: '3YLOU2j85h',
locale: 'ZFe1JLxvBk',
segment: 'G5iUcOa2iG',
addata: '9KyAwgTg1O'
}
var dateSettings = {
dateOverride: ['2017-06-11 09:30:01', 'local'],
language: 'spanish'
}
function useStatic() {
console.log('Index.useStatic()')
}
function failAd() {
console.log('Index.failAd()')
useStatic()
}
function handleVelvetInit() {
console.log('Index.handleVelvetInit()')
// sample get data and date schedule usage
var tunein = Velvet.get('game.date')
var schedule = new DateSchedule({
target: new TzDate({
datetime: tunein.datetime,
outputTimezone: tunein.timezone
}),
isStandard: true
})
schedule.print()
}
Velvet.addEventListener(Velvet.events.FAIL, failAd)
Velvet.addEventListener(Velvet.events.STATIC, useStatic)
Velvet.addEventListener(Velvet.events.INIT, handleVelvetInit)
Velvet.init(slugs, dateSettings, '300x250')
</script>Getting Data
Ad Data from Velvet is JSON. An example looks like:
{
matchups: {
value: [
{
tuneIn: {
value: {
timezone: "US/Pacific",
datetime: "2018-06-26T18:00:00+00:00"
},
type: "LocalizedDateTime"
},
liveURL: {
value: "https://www.fifa.com/worldcup/matches/ match/300331534/#match-liveblog",
type: "URL"
},
],
type: "CollectionMultiItem"
}
}In which case, queries for data would look like:

For more advanced queries, check out the API section.
Capture
Velvet can generate video and image captures of an ad. This is a very powerful feature, when you need to generate a lots of static assets with different creative, messaging, and tune-ins.
To use Velvet Capture, build an HTML unit for Velvet, rather than unique Photoshop & After Effects projects for each.
The following API calls demonstrate the required Capture setup:
// Communicates that data has been consumed and pass that back.
// Even if no data has been added, this call must happen before adStart & adComplete
Velvet.capture.dispatchData()
// When loading is complete and the ad begins
Velvet.capture.adStart()
// When ad animation is complete and the ad has reached its final state
Velvet.capture.adComplete()Another Capture aspect is working with DateSchedule to set up scheduled messaging and ad states:
// OPTIONAL - add a DateSchedule for scheduled messaging changes
Velvet.capture.addSchedule(myScheduleInstance)
// OPTIONAL - add some custom data that gets passed to the ad via the query parameters
Velvet.capture.addCustomData({ type: 'yellow' })For more advanced queries, check out the API section.
Concepts
Programatic advertising enables Brands to reach their demographics with specific impressions & messages.
Building out ads for all of those targets can be an exhausting process, due to the terrific amount of redundancy, asset management and delivery juggling. It's often preferable to build a dynamic unit that can account for many targets in one shot.
Content Management Platforms (CMP's) are the mechanism that help brand managers organize this volume, while reducing the number of builds necessary to produce those targets. Some popular options are:
- DoubleClick Studio (Google Dynamic Content)
- Flashtalking
- Sizmek
There are many others. How is Velvet different?
- Velvet has powerful tools for modeling data. Dynamic scenarios quickly create time-consuming redundancies throughout a campaign. Velvet offers powerful tools for building/managing re-usable data-templates. These components can be widely repurposed, even between different campaigns.
- Velvet is Ad Network agnostic. As an agency ourselves, we understand that brands already have their media deals in place. However, as a production unit, the agency has preferences for how they most easily generate these deliverables. Velvet enables the agency to generate that volume without sacrificing home-grown capabilities.
- Velvet is smooth for producers. Once the data is modeled, and the ads are built to respond to it, producers can manage long runs of evolving content, without the need to rebuild any creative, often times without the need to re-traffic.
- Velvet is flexible for developers. Agencies on the forefront of banner development have systems in place for generating lightweight, attractive content. Velvet is compatible with your stack.
API
Velvet
- .capture
- .schedule(schedule)
- .addCustomData(obj)
- .dispatchData()
- .dispatchSchedule()
- .dispatchStart() ⇒ Promise
- .events
- .INIT : string
- .FAIL : string
- .STATIC : string
- .init(slugs, dateSettings, adDimensions, adElement)
- .isPreviewLocation()
- .convertBreaks(str)
- .get(arguments)

