dailymotion / vast-client-js

VAST (up to 6) parsing library for JavaScript
https://iabtechlab.com/wp-content/uploads/2022/09/VAST_4.3.pdf
MIT License
367 stars 215 forks source link

what are the necessary steps to play an inline vast #453

Closed alixTal closed 1 year ago

alixTal commented 1 year ago

Hi, I'm new to VAST ads and trying to implement vast ads to my video player. I'm confused about what steps I should take to play a vast ad. so we first parse the vast response and then pass it to VASTTracker.

const vastClient = new VAST.VASTClient();

const parsedVAST = await vastClient.get('https://www.examplevast.com/vast.xml');
const vastTracker = new VAST.VASTTracker(vastClient, parsedVAST.ads, parsedVAST.ads[0].creatives);

now we get the creative media file and pass it to our video player and when the video is ready we call vastTracker.trackImpression(); after this, there are some TrackingEvents that I think we should take care of, one problem that I have is I don't know how to trigger these events, here is an example of tracking start events that won't work.

adPlayer.addEventListener('timeupdate', e => {
  vastTracker.setProgress(e.target.currentTime);
});

vastTracker.on('start', () => {
 console.log('start event is sent')
});
alixTal commented 1 year ago

I was able to find out why the tracker didn't work, you have to pass one ad and creative to the vastTracker.

const vastTracker = new VAST.VASTTracker(vastClient, parsedVAST.ads[0], parsedVAST.ads[0].creatives[0]);

the only question now I have is when I use this google ads VAST tag: https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator= track Impression url has this parameter uach_m=[UACH] when I use Google IMA SDK this parameter is filled with some character but when I use vast-client parameter is just uach_m=[UACH] is it something important or just something that IMA SDK does?

Rapha0511 commented 1 year ago

Hello,

Yes, It's only used and replaced by IMA SDK. It's not a required macro nor a standarized one. The vast-client only supports the official macros listed in the IAB specification (https://interactiveadvertisingbureau.github.io/vast/vast4macros/vast4-macros-latest.html).

FYI: You cannot provide custom macro in the vast tracker helpers parameter. (https://github.com/dailymotion/vast-client-js/blob/master/docs/api/vast-tracker.md#trackimpressionmacros-). The vast client will not replace it.

Alternatively, once your VAST file has been parsed, you can go through the object to apply your own filter to the impression URL to replace the macro with its value.

I hope I've answered your question!