Topics API برای وب

API موضوعات، تبلیغات مبتنی بر علاقه را بدون استفاده از کوکی‌های شخص ثالث فعال می‌کند.

How the Topics API works

The Topics API can be used to observe and provide access to topics that appear to be of interest to the user, based on their activity. The Topics API can then give API callers (such as ad tech platforms) access to a user's topics of interest, but without revealing additional information about the user's activity.

Key concepts

  • A topic is a human-readable topic of interest for the current user and is part of the Topics taxonomy.
  • A caller is an entity, such as an app, a third-party SDK, a website, or service, that makes a request to the Topics API to observe or access a user's interests.
  • A topic is observed by a caller, if the caller made a Topics API request from a web page or app associated with this topic during the past three epochs.
  • An epoch is a period of topic computation, which defaults to one week.
  • A taxonomy is a hierarchical list of categories, which includes, for example, such categories as /Arts & Entertainment/Music & Audio/Soul & R&B and /Business & Industrial/Business Services/Corporate Events.
  • Topics are derived using a classifier model that maps user activity to zero or more topics.

Topics API flow core steps

The Topics API lifecycle has three main steps:

  • Observe user activity, such as when they visit the web page https://cats.example/tabby/index.html or download the app cats.
  • Derive topics from user activity, for example /Pets & Animals/Pets/Cats.
  • Access topics previously observed for the user, for example as a signal to select relevant advertising (such as a cat food promotion).

Observe topics

Callers can only access topics of interest that they've observed. A caller observes a topic when they make a Topics API request from a context associated with this topic. To illustrate this concept, consider the following simplified example.

  • Suppose there are two Topics API callers: A and B.
  • There are two contexts:
    • Greenhouse, for example an app named Greenhouse or a website greenhouse.example, associated with the topic Home & Garden.
    • Tennis exercises, for example an app named Tennis Exercises or a website tennis.example, associated with the topic Sports/Tennis.
  • Both caller A and B are present in the context of Greenhouse.
  • Only the caller B is present in the context of Tennis exercises.
  • Assume that no topics were observed for the user before epoch 1, for the sake of simplification.
  • The user visits the Greenhouse app, and callers A and B make a Topics API call to record the user visit to the page or app (see the implementation guide suggested in Next steps to find out how to call the Topics API). This record (a hostname or app data) is later used to derive topics of interest. The Topics API will later mark the topic Home & Garden as observed by both callers A and B.
  • The user visits the Tennis exercises app. Only the caller B sends a Topics API request. The Topics API will later mark the topic Sports/Tennis as observed by the caller B.
  • By the end of the epoch, the Topics API refreshes the user's top topics and determines the callers that observed these topics based on user activity.
  • Later, when the caller B makes another Topics API call, it can get either Home & Garden or Sports/Tennis topic (or, with a 5% chance, a random topic) for this user in the response array.
  • Caller A can only access the topic Home & Garden, as it has never observed the topic Sports/Tennis. This means that a third-party will only learn about a user's topic of interest within the specific context (app or website) where it is present.
Diagram showing that the Topics API only marks the topics as observed if the callers has presence in the context.
The Topics API marks the topics observed only by the callers that have presence in the context of these topics. The callers will only be able to access the topics they have observed.

Derive topics

Topics derives topics of interest from user activity. The topics are selected from a predefined open-source taxonomy. Once per epoch, Topics refreshes the user's top five topics and the callers that observed them during the epoch. The Topics classifier model derives topics from user activity: hostname for a web page visit, app information on Android.

Caller accesses user's topics of interest

The API returns only topics that have been observed by the caller within the most recent three epochs. A maximum of three topics may be returned to a caller,one topic for each of the three recent epochs (if the caller observed topics for that epoch). The returned topics can be used by the caller to supplement any contextual information and can be combined to help find a more relevant ad for the user.

Epochs

The Topics API must ensure that the topics of interest it provides are kept up to date. The topics are inferred for a user based on their activity during a period of time known as an epoch, one week by default. Each user has their own epochs (epochs are "per user") and the initial start time is randomized.

Once each epoch, the Topics API computes the user's top five topics and determines which callers observed those topics using on-device information. The topic selected for each epoch is randomly selected from the user's top five topics for that time period. To further enhance privacy and ensure that all topics may be represented, there is a 5% chance the topic is randomly selected from all possible topics in the taxonomy of interests.

مباحث کاربردی در وب

در وب، موضوعات از نام میزبان صفحاتی که کاربر بازدید می‌کند استنباط می‌شوند. برای مثال، موضوع استنباط شده برای وب‌سایت dogs.example می‌تواند /Pets & Animals/Pets/Dogs باشد.

نمودار زیر یک مثال ساده‌شده را نشان می‌دهد که نشان می‌دهد چگونه API موضوعات می‌تواند به یک پلتفرم فناوری تبلیغات در انتخاب یک تبلیغ مناسب کمک کند. این مثال فرض می‌کند که مرورگر کاربر از قبل مدلی برای نگاشت نام میزبان وب‌سایت به موضوعات دارد.

نموداری که مراحل چرخه عمر API موضوعات را نشان می‌دهد، از بازدید کاربر از وب‌سایت‌ها تا نمایش تبلیغ.
نمودار چرخه عمر API مربوط به موضوعات، مراحل اقدامات API را از دیدگاه سطح بالا بررسی می‌کند.

مرورگر، مبدا فراخوانی‌کننده را از متن کدی که API مربوط به Topics را فراخوانی می‌کند، تشخیص می‌دهد. در عمل، این بدان معناست که کاربران Topics، API را در یک iframe از مبدا خود فراخوانی می‌کنند یا تاپیک‌ها را در یک واکشی به مبدا خود قرار می‌دهند.

برای مثال، یک پلتفرم سمت عرضه (SSP) می‌تواند در سایت‌های چندین ناشر تعبیه شود. سپس SSP می‌تواند API موضوعات را در یک iframe از مبدا خود فراخوانی کند و به آن اجازه دهد موضوعات مرتبط با یک کاربر را در سایت‌های آن ناشر مشاهده کند. سپس این موضوعات می‌توانند با یک پلتفرم سمت تقاضا (DSP) به اشتراک گذاشته شوند تا به آن در انتخاب یک تبلیغ مرتبط برای کاربر کمک کنند.

چگونه API تصمیم می‌گیرد که کدام تماس‌گیرنده‌ها کدام تاپیک‌ها را ببینند

فراخوانندگان API فقط موضوعاتی را دریافت می‌کنند که اخیراً مشاهده کرده‌اند، و موضوعات برای یک کاربر هر بار در هر دوره (epoch) به‌روزرسانی می‌شوند: یک دوره زمانی که در پیاده‌سازی کروم روی یک هفته تنظیم شده است. این بدان معناست که API یک پنجره غلتان فراهم می‌کند که در آن یک فراخواننده معین می‌تواند موضوعات مشاهده شده را دریافت کند.

جدول زیر مثالی (هرچند به طور غیرواقعی کوچک) از تاریخچه مرور فرضی یک کاربر در طول یک دوره زمانی واحد را نشان می‌دهد که موضوعات مرتبط با سایت‌هایی که بازدید کرده‌اند و فراخوان‌های API موجود در هر سایت (موجودیت‌هایی که document.browsingTopics() را در کد جاوا اسکریپت موجود در سایت فراخوانی می‌کنند) را نشان می‌دهد.

سایت مباحث تماس‌گیرندگان API در محل
مثال در حال اجرا Running & Walking
Athletic Shoes
مثال adtech1
مثال adtech2
سگ‌ها.مثال Dogs مثال adtech1
مثال تعطیلات Hotels & Accommodations مثال adtech2
عینک آفتابی.مثال Sunglasses [هیچکدام]

در پایان دوره (به طور پیش‌فرض یک هفته)، API موضوعات، موضوعات برتر مرورگر را برای آن هفته تولید می‌کند.

  • adtech1.example اکنون واجد شرایط دریافت موضوعات Running & Walking ، Athletic Shoes و Dogs است، زیرا آنها را در running.example و همچنین dogs.example مشاهده کرده است.
  • adtech1.example واجد شرایط دریافت موضوع Hotels & Accommodations برای این کاربر نیست، زیرا در هیچ سایتی که کاربر اخیراً بازدید کرده و با آن موضوع مرتبط باشد، وجود ندارد.
  • adtech2.example موضوعات Running & Walking ، Athletic Shoes و Hotels & Accommodations را دیده است، اما موضوع Dogs را ندیده است.

کاربر از سایت sunglasses.example بازدید کرده است که موضوع Sunglasses را دارد، اما هیچ فراخوانی به API موضوعات در آن سایت انجام نشده است. در حال حاضر، این بدان معناست که موضوع Sunglasses توسط API برای هیچ فراخوانی‌کننده‌ای بازگردانده نمی‌شود.

در هفته دوم، کاربر از سایت دیگری بازدید می‌کند:

سایت مباحث تماس‌گیرندگان API در محل
دوربین‌ها.مثال Camera & Photo Equipment مثال adtech2

علاوه بر این، کدی از adtech2.example به sunglasses.example اضافه می‌شود:

سایت مباحث تماس‌گیرندگان API در محل
عینک آفتابی.مثال Sunglasses مثال adtech2

علاوه بر موضوعات Running & Walking ، Athletic Shoes و Hotels & Accommodations از هفته اول، adtech2.example اکنون می‌تواند موضوعات Camera & Photo Equipment و Sunglasses را نیز دریافت کند - اما نه تا دوره بعدی، هفته سوم. این تضمین می‌کند که اشخاص ثالث نمی‌توانند اطلاعات بیشتری در مورد گذشته کاربر (در این مورد، علاقه به مد) نسبت به آنچه که با کوکی‌ها می‌توانند، کسب کنند.

پس از دو هفته دیگر، اگر کاربر از هیچ سایتی با این موضوعات که شامل کد adtech2.example هستند بازدید نکند، ممکن است موضوعات Running & Walking ، Athletic Shoes و Hotels & Accommodations از فهرست موضوعات واجد شرایط adtech2.example خارج شوند.

مراحلی که API موضوعات هنگام بازدید کاربران از سایت‌هایی که از API استفاده می‌کنند، انجام می‌دهد.
نحوه مشاهده و دسترسی API به موضوعات.

مدل طبقه‌بندی‌کننده

تاپیکز از یک مدل طبقه‌بندی استفاده می‌کند که نام‌های میزبان وب‌سایت را به صفر یا چند تاپیک نگاشت می‌کند (تجزیه و تحلیل اطلاعات اضافی، مانند URL های کامل یا محتوای صفحه، ممکن است امکان تبلیغات مرتبط‌تر را فراهم کند، اما می‌تواند حریم خصوصی را نیز کاهش دهد).

طبقه‌بندی

موضوعات از یک طبقه‌بندی انتخاب می‌شوند. این موضوعات توسط کروم گردآوری شده‌اند، با این هدف که طبقه‌بندی به منبعی تبدیل شود که توسط مشارکت‌کنندگان مورد اعتماد اکوسیستم نگهداری می‌شود. طبقه‌بندی باید به اندازه‌ای کوچک باشد که مرورگرهای بسیاری از کاربران با هر موضوع مرتبط باشند. هدف نهایی این است که طبقه‌بندی از یک طرف خارجی که بازخوردها و ایده‌های سراسر صنعت را در بر می‌گیرد، تهیه شود.

برای جلوگیری از دسته‌بندی‌های حساس، موضوعات باید عمومی، توسط انسان انتخاب شده و به‌روز باشند. طبقه‌بندی مورد استفاده کروم توسط انسان انتخاب شده است تا دسته‌بندی‌هایی که عموماً حساس تلقی می‌شوند، مانند قومیت یا گرایش جنسی، را حذف کند .

دسته‌بندی موضوعات

موضوعات به صورت دستی برای ۵۰،۰۰۰ سایت برتر انتخاب می‌شوند و این فهرست جایگزین انتخاب شده از نام‌های میزبان و موضوعات برای آموزش مدل طبقه‌بندی کننده استفاده می‌شود. برای سایت‌های برتر، موضوعات از فهرست جایگزین به جای استفاده از مدل طبقه‌بندی کننده قابل دسترسی هستند. می‌توانید فهرست جایگزین را به صورت محلی در رایانه خود مشاهده کنید .

صفحه chrome://topics-internals با پنل Classifier انتخاب شده.
پنل طبقه‌بندی صفحه chrome://topics-internals نسخه مدل، مسیر آن و موضوعات مرتبط با هر میزبان فهرست‌شده را فهرست می‌کند.

پیاده‌سازی API مربوط به Topics در کروم، یک فایل TensorFlow Lite را دانلود می‌کند که نشان‌دهنده‌ی مدل است و بنابراین می‌توان آن را به صورت محلی روی دستگاه کاربر استفاده کرد.

نحوه انتخاب پنج موضوع برتر کاربر

این API برای هر دوره (epoch) یک موضوع و حداکثر سه موضوع برمی‌گرداند. اگر سه موضوع برگردانده شود، این شامل موضوعات دوره فعلی و دو دوره قبلی می‌شود.

  1. در پایان هر دوره، مرورگر فهرستی از صفحاتی را که معیارهای زیر را دارند، گردآوری می‌کند:
    • این صفحه در طول دوره توسط کاربر بازدید شده است.
    • این صفحه شامل کدی است که document.browsingTopics() را فراخوانی می‌کند.
    • API فعال شده است (برای مثال، توسط کاربر یا توسط هدر پاسخ مسدود نشده است).
  2. مرورگر، در دستگاه کاربر، از مدل طبقه‌بندی ارائه شده توسط API موضوعات برای نگاشت نام میزبان هر صفحه به لیستی از موضوعات استفاده می‌کند.
  3. مرورگر فهرستی از پنج موضوع برتر را تولید می‌کند.

    • هر یک از ۲۲ موضوع ریشه در طبقه‌بندی، بر اساس بازخورد از اکوسیستم تبلیغات، به یک سطل «کاربرد بالا» یا «کاربرد استاندارد» اختصاص داده می‌شود. مرورگر ابتدا موضوعات را بر اساس تخصیص سطل آنها مرتب می‌کند. همه موضوعات زیرمجموعه، تخصیص سطل موضوع ریشه والد خود را به ارث می‌برند. موضوعات «کاربرد بالا» اولویت‌بندی می‌شوند.
    • سپس مرورگر موضوعات را بر اساس فراوانی در هر دسته مرتب می‌کند.
    • پنج موضوع برتر از این لیست مرتب‌شده، به عنوان موضوعات برتر کاربر برای آن دوره انتخاب می‌شوند.

سپس متد document.browsingTopics() برای هر دوره، یک موضوع تصادفی از بین پنج موضوع برتر را برمی‌گرداند، با احتمال ۵٪ که هر یک از این موضوعات به طور تصادفی از طبقه‌بندی کامل موضوعات انتخاب شوند. در کروم، کاربران همچنین می‌توانند موضوعات را به صورت جداگانه حذف کنند یا تاریخچه مرور خود را پاک کنند تا تعداد موضوعات برگردانده شده توسط API کاهش یابد. کاربران همچنین می‌توانند از API خارج شوند .

شما می‌توانید اطلاعات مربوط به موضوعات مشاهده شده در دوره فعلی را از صفحه chrome://topics-internals مشاهده کنید.

Next steps

Get your environment ready to test and develop web applications with the Topics API.
Check out implementation details and code samples for callers to observe and access topics.

See also

Check out our resources to better understand the Topics API on the Web.