Ads

Module for handling pre-defined ad slots and dynamically generated ad slots.

Source:
Properties:
Name Type Description
gptAdPath string

ad unit path

states.loaded string

CSS class for div with ad loaded

states.empty string

CSS Class for empty ad div

states.hidden string

CSS class for hiding an element

ads Object

all pre-defined ad slots and data

watcher Object

in view watcher for lazy loading of ads

Methods

(inner) amazonBiddingSupported()

Source:

Check if apstag amazon bidding is available

(inner) broadcastLoaded($el)

Source:

Call this function when an ad unit has been loaded

Parameters:
Name Type Description
$el Object

an element reference to the ad div that is ready to load

(inner) createAd(ad)

Source:

Create dynamic ads that are not defined in the markup

Parameters:
Name Type Description
ad Object

ad data used for creating an ad

(inner) display(ads)

Source:

Display ads via ad bidding or regular ad refresh

Parameters:
Name Type Description
ads Array

An array of ad objects

(inner) getAds(attr, filter) → {Array}

Source:

Get all registered ad data and ad slot.

Parameters:
Name Type Description
attr String

optional. When provided, retrieve the property of each ad

filter Object

optional. Filters results by key/value specified in $filter

Returns:
  • All registered ads or an array of attributes of register ads
Type
Array

(inner) init()

Source:

Scrape global variable gnAdSettings defined on the page to define ad slots, set up page targeting, and set up listeners for ad loaded events

(inner) initialRequestMade()

Source:

Check if initial ad request made.

(inner) refresh(ads)

Source:

Refresh ads specified by an array of ad objects.

Note: Currently, all we have to do is call display(), but in case anything changes in the future where refreshing of ads need to behave differently we can update this function.

Parameters:
Name Type Description
ads Array

An array of ad objects

(inner) registerAd(ad)

Source:

Register ad related data to be retrieved for ad bidding. Add inView event listener to trigger lazy load ads.

Parameters:
Name Type Description
ad Object

div id, slot defined via googletag, ad size mapping for responsive ads

(inner) requestOnPageLoad()

Source:

Request all non-lazy and in view ads on page load