Stay organized with collections
Save and categorize content based on your preferences.
NonceManager
classpublic
Manages a nonce and its event reporting for a single content playback
session.
The content playback session lifecycle methods, including sendAdClick,
sendAdTouch, sendPlaybackStart, and sendPlaybackEnd must be called as
these respective events occur in order to enable programmatic monetization.
Methods
getNonce
public
getNonce() returns string
Returns
string The nonce generated for this manager when it was loaded.
This value will never change for a given NonceManager instance. This
nonce value is only valid for a single content playback session up to a
maximum duration of 6 hours.
sendAdClick
public
sendAdClick() returns void
Notifies Google ad servers that a clickthrough on an ad has occurred during
the given content playback session.
Returns
void
sendAdImpression
public
sendAdImpression() returns void
Should be called when the first frame of the ad that was requested with
the nonce generated by this manager is displayed.
Deprecated
Use `sendPlaybackStart` and `sendPlaybackEnd` instead.
Returns
void
sendAdTouch
public
sendAdTouch(clickOrTouchEvent) returns void
Notifies Google ad servers that a user touch or click on the ad other than
a clickthrough (for example, skip, mute, tap, and more.) has occurred
during the given content playback session.
Parameter
clickOrTouchEvent
(non-null MouseEvent or non-null TouchEvent)
The browser touch or click event that was fired
for the user interaction.
Returns
void
sendPlaybackEnd
public
sendPlaybackEnd() returns void
Notifies Google ad servers that playback for the given content playback
session has ended. This should be called when playback ends (for example,
when the player reaches end of stream, or when the user exits playback
mid-way, or when the user leaves the page, or when advancing to the next
content item in a playlist setting).
This method ends the asynchronous calls to Google servers started in
sendPlaybackStart.
Returns
void
sendPlaybackStart
public
sendPlaybackStart() returns void
Notifies Google ad servers that playback for the given content playback
session has started. This should be called on "video player start". This
may be in response to a user-initiated action (click-to-play) or a page
initiated action (autoplay).
This method will start asynchronous calls to Google servers to collect
signals needed for IVT monitoring and detection.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[[["\u003cp\u003eNonceLoader is a programmatic access library that helps publishers unlock AdX demand by collecting signals.\u003c/p\u003e\n"],["\u003cp\u003ePublishers need to create a NonceLoader instance upon page load and utilize its methods to generate and manage nonces for ad requests.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eloadNonceManager\u003c/code\u003e is called to obtain a NonceManager which provides the nonce to include in ad requests via the \u003ccode\u003e&paln\u003c/code\u003e URL parameter.\u003c/p\u003e\n"],["\u003cp\u003eNonceManager also provides methods for signaling ad clicks and impressions (\u003ccode\u003esendAdClick\u003c/code\u003e and \u003ccode\u003esendAdImpression\u003c/code\u003e).\u003c/p\u003e\n"]]],["The `NonceManager` class manages a unique nonce for a single content playback session, valid for up to 6 hours. Key actions include: `getNonce()` to retrieve the session's nonce; `sendPlaybackStart()` to initiate server communication at playback start; `sendPlaybackEnd()` to signal playback completion; `sendAdClick()` for clickthrough events; and `sendAdTouch()` for other user interactions. The deprecated `sendAdImpression` will be replaced by the use of `sendPlaybackStart` and `sendPlaybackEnd`.\n"],null,["NonceManager \nclass public\n\nManages a nonce and its event reporting for a single content playback\nsession.\nThe content playback session lifecycle methods, including `sendAdClick`,\n`sendAdTouch`, `sendPlaybackStart`, and `sendPlaybackEnd` must be called as\nthese respective events occur in order to enable programmatic monetization.\n\nMethods\n\ngetNonce \npublic\n\ngetNonce() returns string\n\nReturns\n\n: `string` The nonce generated for this manager when it was loaded.\n This value will never change for a given `NonceManager` instance. This\n nonce value is only valid for a single content playback session up to a\n maximum duration of 6 hours.\n\nsendAdClick \npublic\n\nsendAdClick() returns void\n\nNotifies Google ad servers that a clickthrough on an ad has occurred during\nthe given content playback session.\n\nReturns\n\n: `void`\n\nsendAdImpression \npublic\n\nsendAdImpression() returns void\n\nShould be called when the first frame of the ad that was requested with\nthe nonce generated by this manager is displayed.\n\nDeprecated\n: Use \\`sendPlaybackStart\\` and \\`sendPlaybackEnd\\` instead.\n\nReturns\n\n: `void`\n\nsendAdTouch \npublic\n\nsendAdTouch(clickOrTouchEvent) returns void\n\nNotifies Google ad servers that a user touch or click on the ad other than\na clickthrough (for example, skip, mute, tap, and more.) has occurred\nduring the given content playback session.\n\n| Parameter ||\n|-------------------|------------------------------------------------------------------------------------------------------------------------|\n| clickOrTouchEvent | (non-null MouseEvent or non-null TouchEvent) The browser touch or click event that was fired for the user interaction. |\n\nReturns\n\n: `void`\n\nsendPlaybackEnd \npublic\n\nsendPlaybackEnd() returns void\n\nNotifies Google ad servers that playback for the given content playback\nsession has ended. This should be called when playback ends (for example,\nwhen the player reaches end of stream, or when the user exits playback\nmid-way, or when the user leaves the page, or when advancing to the next\ncontent item in a playlist setting).\n\nThis method ends the asynchronous calls to Google servers started in\n`sendPlaybackStart`.\n\nReturns\n\n: `void`\n\nsendPlaybackStart \npublic\n\nsendPlaybackStart() returns void\n\nNotifies Google ad servers that playback for the given content playback\nsession has started. This should be called on \"video player start\". This\nmay be in response to a user-initiated action (click-to-play) or a page\ninitiated action (autoplay).\n\nThis method will start asynchronous calls to Google servers to collect\nsignals needed for IVT monitoring and detection.\n\nReturns\n\n: `void`"]]