clearPageTargetingForKey
Global Function
Removes page targeting for a specified key from GPT ad calls
Links
setPageCollapseEmpty
Global Function
Sets behaviour of empty slots can be 'after', 'before' or 'never'
- 'after' collapse slots that return an empty ad
- 'before' collapses all slots and only displays them when an ad is found
- 'never' does not collapse any empty slot, the collapseEmptyDivs method is not called in that case
Links
enableCompanions
Global Function
When companions are enabled we delay the rendering of ad slots until
either a master is returned or all slots are returned without a master
Links
updateCorrelator
Global Function
The correlator is a random number added to ad calls.
It is used by the ad server to determine which impressions where served to the same page
Updating is used to tell the ad server to treat subsequent ad calls as being on a new page
Links
Moat
Global Function
we use a third party script from moat to determine invalid traffic.
In ft.com this lives in n-ui.
The script exposes window.moatPrebidApi
object which we check for here.
The script essentially ads some extra targeting parameters to the ad calls,
and if the validateAdsTraffic option is enabled, we need to wait for it to
be available before making any ad calls.
Links
defaults
Global Property
Default configuration set in the constructor.
Links
new Config
Defines a store for configuration information and returns a getter/setter method for access.
Links
new Krux
The Krux class defines an FT.ads.krux instance
Links
new Slot
The Slot class.
Methods
-
parseAttributeConfig
- (instance) parse slot attribute config
-
initLazyLoad
- (instance) Load a slot when it appears in the viewport
-
initResponsive
- (instance) Listen to responsive breakpoints and collapse slots
where the configured size is set to false
-
maximise
- (instance) Maximise the slot when size is 100x100
-
setName
- (instance) If the slot doesn't have a name give it one
-
setResponsiveCreative
- (instance) If the slot doesn't have a name give it one
-
collapse
- (instance) add the empty class to the slot
-
setFormatLoaded
- (instance) sets a classname of the format
-
uncollapse
- (instance) remove the empty class from the slot
-
clear
- (instance) call the ad server clear method on the slot if one exists
-
destroy
- (instance) call the ad server destroySlot method on the slot if one exists
-
submitImpression
- (instance) call the ad server impression URL for an out of page slot if it has been configured correctly for delayed impressions
-
fire
- (instance) fire an event on the slot
-
addContainer
- (instance) add a div tag into the current slot container
-
centerContainer
- (instance) Add a center class to the main container
-
labelContainer
- (instance) Add a label class to the main container
Links
new Slots
The Slots instance tracks all ad slots on the page
configures global page events used by a slot and
provides utlity methods that act on all slots
Methods
-
collapse
- (instance) Given a slot name or an array of slot names will collapse the slots using the collapse method on the slot
-
uncollapse
- (instance) Given a slot name or an array of slot names will uncollapse the slots using the uncollapse method on the slot
-
refresh
- (instance) Given a slot name or an array of slot names of slotnames will refresh the slots using the refresh method on the slot
-
clear
- (instance) Given a slot name or an array of slot names will clear the slots using the clear method on the slot
-
destroy
- (instance) Given a slot name or an array of slot names will destroy the slots using the destroySlot method on the slot and remove the reference to the slot
-
submitImpression
- (instance) Given a slot name will submit a delayed impression for the slot
-
initSlot
- (instance) Confirms a container in the page exists and creates a Slot object
Links
module:utils/events
Utility methods for o-ads events. Methods defined here are added to the utils object not the utils.event object.
Properties
-
broadcast
-
Broadscasts an o-ads event
-
on
-
Sets an event listener for an oAds event
-
off
-
Removes an event listener for an oAds event
-
once
-
Sets a one time event listener for an oAds event
Links
module:utils
Utility methods for the advertising library.
Methods
-
isWindow(obj)
- (static) Test if an object is the global window object
-
isPlainObject(obj)
- (static) Test if an object inherits from any other objects, used in extend
to protect against deep copies running out of memory and constructors
losing there prototypes when cloned
-
isNonEmptyString(str)
- (static) Test if an object is a string with a length
-
extend(...)
- (static) Merge or clone objects
-
hash(...)
- (static) Create an object hash from a delimited string
Beware all properties on the resulting object will have string values.
-
attach(...)
- (static) Takes a script URL as a string value, creates a new script element, sets the src and attaches to the page
The async value of the script can be set by the seccond parameter, which is a boolean
Note, we should use protocol-relative URL paths to ensure we don't run into http/https issues
-
dehyphenise(string)
- (static) Remove hyphens from a string and upper case the following letter
-
parseAttributeName(attribute)
- (static) remove prefixes from o-ads data attributes and dehyphenise the name
-
getQueryString
- (static) return the current documents search or an empty string if non exists
also strips the initial ? from the search string for easier parsing
This method enables us to mock the search string in our tests reliably and doesn't really serve any other purpose
-
getQueryParamByName(name, url)
- (static) Get a query string parameter by name from a url
-
getTimestamp
- (static) returns a timestamp of the current date/time in the format YYYYMMDDHHMMSS
-
iframeToSlotName(a)
- (static) Given the window object of an iframe this method returns the o-ads slot name
that rendered the iframe, if the iframe was not rendered by o-ads this will
return false
Links
module:utils/log
Utility methods for logging.
Methods
-
isOn(type)
- (static) Determine if debug logging is on and if the type if supported
-
warn
- (static) Log a warning message
-
error
- (static) Log an error message
-
info
- (static) Log an info message
-
start(group)
- (static) Start a collapsed group
-
end
- (static) End a collapsed group
Links
module:utils/log(type, args)
Safe logger for the browser
Methods
-
isOn(type)
- (static) Determine if debug logging is on and if the type if supported
-
warn
- (static) Log a warning message
-
error
- (static) Log an error message
-
info
- (static) Log an info message
-
start(group)
- (static) Start a collapsed group
-
end
- (static) End a collapsed group
Links
module:utils
Utility methods for postMessage api.
Methods
-
isWindow(obj)
- (static) Test if an object is the global window object
-
isPlainObject(obj)
- (static) Test if an object inherits from any other objects, used in extend
to protect against deep copies running out of memory and constructors
losing there prototypes when cloned
-
isNonEmptyString(str)
- (static) Test if an object is a string with a length
-
extend(...)
- (static) Merge or clone objects
-
hash(...)
- (static) Create an object hash from a delimited string
Beware all properties on the resulting object will have string values.
-
attach(...)
- (static) Takes a script URL as a string value, creates a new script element, sets the src and attaches to the page
The async value of the script can be set by the seccond parameter, which is a boolean
Note, we should use protocol-relative URL paths to ensure we don't run into http/https issues
-
dehyphenise(string)
- (static) Remove hyphens from a string and upper case the following letter
-
parseAttributeName(attribute)
- (static) remove prefixes from o-ads data attributes and dehyphenise the name
-
getQueryString
- (static) return the current documents search or an empty string if non exists
also strips the initial ? from the search string for easier parsing
This method enables us to mock the search string in our tests reliably and doesn't really serve any other purpose
-
getQueryParamByName(name, url)
- (static) Get a query string parameter by name from a url
-
getTimestamp
- (static) returns a timestamp of the current date/time in the format YYYYMMDDHHMMSS
-
iframeToSlotName(a)
- (static) Given the window object of an iframe this method returns the o-ads slot name
that rendered the iframe, if the iframe was not rendered by o-ads this will
return false
Links
Ads#init(options)
Instance Method
Initialises the ads library and all sub modules
Links
slotMethods.defineSlot
Static Method
define a GPT slot
Links
slotMethods.destroySlot
Static Method
Tell gpt to destroy the slot and its metadata
Links
slotMethods.setUnitName
Static Method
Set the DFP unit name for the slot.
Links
slotMethods.addServices
Static Method
Add the slot to the pub ads service and add a companion service if configured
Links
slotMethods.setCollapseEmpty
Static Method
Sets the GPT collapse empty mode for a given slot
values can be 'after', 'before', 'never'
Links
slotMethods.setURL
Static Method
Sets page url to be sent to google
prevents later url changes via javascript from breaking the ads
Links
slotMethods.setTargeting
Static Method
Adds key values from a given object to the slot targeting
Links
FT.ads.config
Static Method
The FT.ads.config object holds the confiuration properties for an FT.ads.gpt instance.
There are four tiers of configuration; cookie level config, default config (set within the constructor), metatag config and global (env) config.
Global config, (set in the page FT.env ojbect) takes priority over meta followed by default config with cookie config having the least priority.
The FT.ads.config() function acts as an accessor method for the config; allowing getting and setting of configuration values.
Calling config() with no parameters returns the entire configuration object.
Calling config passing a valid property key will envoke the 'getter' and return the value for that property key.
Calling config passing a valid property key and a value will envoke the setter and set the value of the key to the new value.
Calling config passing an object of keys and values will envoke a setter that extends the store with the object provided.
Links
Slot#parseAttributeConfig
Instance Method
parse slot attribute config
Links
Slot#initLazyLoad
Instance Method
Load a slot when it appears in the viewport
Links
Slot#initResponsive
Instance Method
Listen to responsive breakpoints and collapse slots
where the configured size is set to false
Links
Slot#maximise
Instance Method
Maximise the slot when size is 100x100
Links
Slot#setName
Instance Method
If the slot doesn't have a name give it one
Links
Slot#setResponsiveCreative
Instance Method
If the slot doesn't have a name give it one
Links
Slot#collapse
Instance Method
add the empty class to the slot
Links
Slot#uncollapse
Instance Method
remove the empty class from the slot
Links
Slot#clear
Instance Method
call the ad server clear method on the slot if one exists
Links
Slot#destroy
Instance Method
call the ad server destroySlot method on the slot if one exists
Links
Slot#submitImpression
Instance Method
call the ad server impression URL for an out of page slot if it has been configured correctly for delayed impressions
Links
Slot#fire
Instance Method
fire an event on the slot
Links
Slot#addContainer
Instance Method
add a div tag into the current slot container
Links
Slot#centerContainer
Instance Method
Add a center class to the main container
Links
Slot#labelContainer
Instance Method
Add a label class to the main container
Links
Slots#collapse
Instance Method
Given a slot name or an array of slot names will collapse the slots using the collapse method on the slot
Links
Slots#uncollapse
Instance Method
Given a slot name or an array of slot names will uncollapse the slots using the uncollapse method on the slot
Links
Slots#refresh
Instance Method
Given a slot name or an array of slot names of slotnames will refresh the slots using the refresh method on the slot
Links
Slots#clear
Instance Method
Given a slot name or an array of slot names will clear the slots using the clear method on the slot
Links
Slots#destroy
Instance Method
Given a slot name or an array of slot names will destroy the slots using the destroySlot method on the slot and remove the reference to the slot
Links
Slots#submitImpression
Instance Method
Given a slot name will submit a delayed impression for the slot
Links
Slots#initSlot
Instance Method
Confirms a container in the page exists and creates a Slot object
Links
Targeting#getFromConfig
Instance Method
getFromConfig returns an object containing all the key values pairs specified in the dfp_targeting
config.
Links
Targeting#socialFlow
Instance Method
If there is a query parameter called socialflow=xxx, we need to add it
as a tag
Links
module:utils/events.broadcast
Static Property
Broadscasts an o-ads event
Links
module:utils/events.on
Static Property
Sets an event listener for an oAds event
Links
module:utils/events.off
Static Property
Removes an event listener for an oAds event
Links
module:utils/events.once
Static Property
Sets a one time event listener for an oAds event
Links
module:utils.isWindow(obj)
Static Method
Test if an object is the global window object
Returns
-
boolean
- true if the object is the window obj, otherwise false
Links
module:utils.isPlainObject(obj)
Static Method
Test if an object inherits from any other objects, used in extend
to protect against deep copies running out of memory and constructors
losing there prototypes when cloned
Returns
-
boolean
- true if the object is plain false otherwise
Links
module:utils.isNonEmptyString(str)
Static Method
Test if an object is a string with a length
Returns
-
boolean
- true if the object is a string with a length greater than 0
Links
module:utils.extend(...)
Static Method
Merge or clone objects
Returns
-
object
- The target object extended with the other params
Links
module:utils.hash(...)
Static Method
Create an object hash from a delimited string
Beware all properties on the resulting object will have string values.
Returns
Links
module:utils.attach(...)
Static Method
Takes a script URL as a string value, creates a new script element, sets the src and attaches to the page
The async value of the script can be set by the seccond parameter, which is a boolean
Note, we should use protocol-relative URL paths to ensure we don't run into http/https issues
Returns
-
HTMLElement
- the created script tag
Links
module:utils.dehyphenise(string)
Static Method
Remove hyphens from a string and upper case the following letter
Returns
Links
module:utils.parseAttributeName(attribute)
Static Method
remove prefixes from o-ads data attributes and dehyphenise the name
Returns
Links
module:utils.getQueryString
Static Method
return the current documents search or an empty string if non exists
also strips the initial ? from the search string for easier parsing
This method enables us to mock the search string in our tests reliably and doesn't really serve any other purpose
Returns
Links
module:utils.getQueryParamByName(name, url)
Static Method
Get a query string parameter by name from a url
Returns
Links
module:utils.getTimestamp
Static Method
returns a timestamp of the current date/time in the format YYYYMMDDHHMMSS
Returns
Links
module:utils.iframeToSlotName(a)
Static Method
Given the window object of an iframe this method returns the o-ads slot name
that rendered the iframe, if the iframe was not rendered by o-ads this will
return false
Returns
Links
module:utils/log.isOn(type)
Static Method
Determine if debug logging is on and if the type if supported
Links
module:utils/log.warn
Static Method
Log a warning message
Links
module:utils/log.error
Static Method
Log an error message
Links
module:utils/log.info
Static Method
Log an info message
Links
module:utils/log.start(group)
Static Method
Start a collapsed group
Links
module:utils/log.end
Static Method
End a collapsed group
Links