קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
NonceManager
classpublic
מנהל את ה-nonce ואת הדיווח על האירועים שלו עבור הפעלת תוכן אחת.
צריך להפעיל את השיטות של מחזור החיים של סשן הפעלת התוכן, כולל sendAdClick,
sendTouch, sendPlaybackStart ו-sendPlaybackEnd, כשהאירועים האלה מתרחשים, כדי להפעיל מונטיזציה פרוגרמטית.
Methods
getNonce
public
getNonce() מחזירה מחרוזת
החזרות
string הערך החד-פעמי שנוצר עבור חשבון הניהול הזה כשהוא נטען.
הערך הזה לא ישתנה אף פעם עבור מופע נתון של NonceManager. הערך הזה של ה-nonce תקף רק לסשן הפעלה יחיד של תוכן, למשך עד 6 שעות.
sendAdClick
public
הפונקציה sendAdClick() מחזירה void
התג הזה מודיע לשרתי המודעות של Google שהתרחש קליק למעבר באתר במודעה במהלך סשן הפעלת התוכן הנתון.
החזרות
void
sendAdImpression
public
sendAdImpression() מחזירה void
הפונקציה הזו צריכה להיקרא כשהפריים הראשון של המודעה שהתבקשה עם הערך החד-פעמי שנוצר על ידי מנהל המודעות הזה מוצג.
הוצא משימוש
במקום זאת, צריך להשתמש ב-`sendPlaybackStart` וב-`sendPlaybackEnd`.
החזרות
void
sendAdTouch
public
sendAdTouch(userInteractionEvent) מחזירה void
התג הזה מודיע לשרתי המודעות של Google שמשתמש הקיש על המודעה או לחץ עליה, ולא לחץ להמשך (למשל, דילוג, השתקה, הקשה וכו'), במהלך הפעלת התוכן בסשן הנתון.
פרמטר
userInteractionEvent
cast.framework.events.Event
אירוע האינטראקציה של המשתמש שהופעל על ידי Cast Framework.
הערך לא יכול להיות null.
החזרות
void
sendPlaybackEnd
public
sendPlaybackEnd() מחזירה void
הפונקציה מודיעה לשרתי המודעות של Google שההפעלה של סשן הפעלת התוכן הספציפי הסתיימה. צריך להפעיל את הפונקציה הזו כשההפעלה מסתיימת (לדוגמה, כשהנגן מגיע לסוף השידור, כשהמשתמש יוצא מההפעלה באמצע, כשהמשתמש עוזב את הדף או כשהוא עובר לפריט התוכן הבא בהגדרת פלייליסט).
השיטה הזו מסיימת את הקריאות האסינכרוניות לשרתי Google שהתחילו ב-sendPlaybackStart.
החזרות
void
sendPlaybackStart
public
sendPlaybackStart() מחזירה void
הודעה לשרתי המודעות של Google שההפעלה של סשן הפעלת התוכן שצוין התחילה. צריך להפעיל את הפונקציה הזו כשמתחילים להפעיל את נגן הווידאו. יכול להיות שהאירוע הזה יתרחש בתגובה לפעולה שהמשתמש יזם (למשל, קליק להפעלה) או לפעולה שהדף יזם (למשל, הפעלה אוטומטית).
השיטה הזו תתחיל קריאות אסינכרוניות לשרתי Google כדי לאסוף אותות שנדרשים למעקב ולזיהוי של תנועת גולשים לא חוקית.
[null,null,["עדכון אחרון: 2025-08-21 (שעון UTC)."],[[["\u003cp\u003eThe NonceManager class manages a unique nonce and reports events for a single content playback session, enabling programmatic monetization.\u003c/p\u003e\n"],["\u003cp\u003eTo enable programmatic monetization, you must call specific lifecycle methods like \u003ccode\u003esendAdClick\u003c/code\u003e, \u003ccode\u003esendTouch\u003c/code\u003e, \u003ccode\u003esendPlaybackStart\u003c/code\u003e, and \u003ccode\u003esendPlaybackEnd\u003c/code\u003e when their corresponding events occur.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetNonce()\u003c/code\u003e provides a unique nonce for the session, valid for a single playback up to 6 hours.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003esendPlaybackStart()\u003c/code\u003e and \u003ccode\u003esendPlaybackEnd()\u003c/code\u003e should be used to signal the start and end of content playback to Google ad servers, replacing the deprecated \u003ccode\u003esendAdImpression\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eOther methods like \u003ccode\u003esendAdClick\u003c/code\u003e and \u003ccode\u003esendAdTouch\u003c/code\u003e allow reporting of ad interactions for comprehensive monetization tracking.\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: retrieving the nonce via `getNonce()`; notifying ad server events with `sendAdClick()`, `sendAdTouch()`, and `sendAdImpression()`; and signaling the start and end of a playback session via `sendPlaybackStart()` and `sendPlaybackEnd()`. `sendPlaybackStart()` begins background monitoring while `sendPlaybackEnd()` concludes it.\n"],null,["# Class: NonceManager\n\nNonceManager\n============\n\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`sendTouch`, `sendPlaybackStart`, and `sendPlaybackEnd` must be called as\nthese respective events occur in order to enable programmatic monetization.\n\nMethods\n-------\n\n### getNonce\n\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 nonce value is only valid for a single content playback session up to a maximum duration of 6 hours.\n\n### sendAdClick\n\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\n### sendAdImpression\n\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\n### sendAdTouch\n\npublic\n\nsendAdTouch(userInteractionEvent) returns void\n\nNotifies Google ad servers that a user touch or click on the ad other than\na clickthrough (e.g. skip, mute, tap, etc.) has occurred during the given\ncontent playback session.\n\n| #### Parameter ||\n|----------------------|-------------------------------------------------------------------------------------------------------------|\n| userInteractionEvent | cast.framework.events.Event The user interaction event fired by the Cast framework. Value must not be null. |\n\nReturns\n\n: `void`\n\n### sendPlaybackEnd\n\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 (e.g. when the\nplayer reaches end of stream, or when the user exits playback mid-way, or\nwhen the user leaves the page, or when advancing to the next content item\nin a playlist setting).\n\nThis method ends the asynchronous calls to Google servers started in\n`sendPlaybackStart`.\n\nReturns\n\n: `void`\n\n### sendPlaybackStart\n\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`"]]