広告クリエイティブをローテーションで表示する

共有ストレージを使用して、複数のサイトでユーザーに表示されるクリエイティブを特定する。

Shared Storage API は、汎用のクロスサイト ストレージに関するプライバシー サンドボックスの提案であり、多くのユースケースに対応しています。たとえば、クリエイティブ ローテーションは、Chrome 104.0.5086.0 以降でテストできます。

クリエイティブ ローテーションを使用すると、クリエイティブ ID、表示回数、ユーザー操作などのデータを保存して、さまざまなサイトでどのクリエイティブ ユーザーが目にするかを決定できます。

共有ストレージ ワークレットを実行し、保存されたデータに基づいて指定されたリストから URL を選択し、そのクリエイティブをフェンス付きフレームにレンダリングします。新しい広告やその他のコンテンツの選択に使用できます。

クリエイティブ ローテーションを試す

共有ストレージでクリエイティブ ローテーションをテストするには、Chrome 104.0.5086.0 以降を使用していることを確認してください。次に、chrome://flags/#privacy-sandbox-ads-apisプライバシー サンドボックスの広告 API のテストフラグを有効にします。

これらの API を使用するには、プライバシー サンドボックスの広告 API のテストを有効に設定します

コマンドラインで --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames フラグを使用して共有ストレージを有効にすることもできます。

コードサンプルでテストする

広告主やコンテンツ制作者は、キャンペーンに異なる戦略を適用し、コンテンツやクリエイティブをローテーションして効果を高めることが必要な場合があります。共有ストレージを使用すると、順次ローテーションや均等に分散ローテーションなど、異なるサイト間でさまざまなローテーション戦略を実行できます。

この例では、次のようになります。

  • creative-rotation.js がフレームに埋め込まれている。このスクリプトは、どの広告が最も重要か(ウェイト)を設定し、ワークレットを呼び出して表示するコンテンツを決定します。
  • creative-rotation-worklet.js は、コンテンツの重み付けされた分散を決定し、表示するコンテンツを返す共有ストレージ ワークレットです。

creative-rotation.js

// Ad config with the URL of the content, a probability weight for rotation, and the clickthrough rate.
const DEMO_CONTENT_CONFIG = [
  {
    url: 'https://your-server.example/contents/content-1.html',
    weight: 0.7,
  },
  {
    url: 'https://your-server.example/contents/content-2.html',
    weight: 0.2,
  },
  {
    url: 'https://your-server.example/contents/content-3.html',
    weight: 0.1,
  },
];

// Set the mode to sequential and set the starting index to 0.
async function seedStorage() {
  await window.sharedStorage.set('content-rotation-mode', 'sequential', {
    ignoreIfPresent: true,
  });

  await window.sharedStorage.set('content-rotation-index', 0, {
    ignoreIfPresent: true,
  });
}

async function injectAd() {
  // Load the worklet module
  await window.sharedStorage.worklet.addModule('content-rotation-worklet.js');

  // Initially set the storage to sequential mode for the demo
  seedStorage();

  // Run the URL selection operation to determine the next content rendered.
  const urls = DEMO_CONTENT_CONFIG.map(({ url }) => ({ url }));
  const fencedFrameConfig = await window.sharedStorage.selectURL('content-rotation', urls, { 
    data: DEMO_CONTENT_CONFIG,
    resolveToConfig: true
  });

  // Render the opaque URL into a fenced frame
  document.getElementById('content-slot').config = fencedFrameConfig;
}

injectAd();

creative-rotation-worklet.js

class SelectURLOperation {
  async run(urls, data) {
    // Read the rotation mode from Shared Storage
    const rotationMode = await this.sharedStorage.get('content-rotation-mode');

    // Generate a random number to be used for rotation
    const randomNumber = Math.random();

    let index;

    switch (rotationMode) {
      /**
       * Sequential rotation
       * - Rotates the contents in order
       * - Example: A -> B -> C -> A ...
       */
      case 'sequential':
        const currentIndex = await this.sharedStorage.get('creative-rotation-index');
        index = parseInt(currentIndex, 10);
        const nextIndex = (index + 1) % urls.length;

        await this.sharedStorage.set('content-rotation-index', nextIndex);
        break;

      /**
       * Weighted rotation
       * - Rotates the contentswith weighted probability
       * - Example: A=70% / B=20% / C=10%
       */
      case 'weighted-distribution':
        
        // Sum the weights cumulatively, and find the first URL where the
        // sum exceeds the random number. The array is sorted in
        // descending order first.
        let weightSum = 0;
        const { url } = data
          .sort((a, b) => b.weight - a.weight)
          .find(({ weight }) => {
            weightSum += weight;
            return weightSum > randomNumber;
          });

        index = urls.indexOf(url);
        break;

      default:
        index = 0;
    }
    return index;
  }
}

register('content-rotation', SelectURLOperation);

ユースケース

上記は、共有ストレージのユースケースのほんの一例です。今後もフィードバックをいただき、新しいユースケースを発見する際に、例を追加していく予定です。

コンテンツの選択

共有ストレージで収集された情報に基づいて、さまざまなコンテンツを選択し、フェンス付きフレームでさまざまなウェブサイトのさまざまなコンテンツを選択して表示します。これらのユースケースの出力ゲートは URL の選択です。

  • クリエイティブ ローテーション: クリエイティブ ID、視聴回数、ユーザー インタラクションなどのデータを保存して、さまざまなサイトでどのクリエイティブをユーザーが目にするかを決定します。
  • A/B テスト: ユーザーをテストグループに割り当てて、そのグループを共有ストレージに保存して、クロスサイトでアクセスできるようにします。
  • カスタム ユーザー エクスペリエンス: ユーザーの登録ステータスなどのユーザー状態に基づいて、カスタム コンテンツと行動を促すフレーズを共有します

概要レポートを生成する

共有ストレージを使用して情報を収集し、ノイズの多い集計概要レポートを生成する。これらのユースケースの出力ゲートは Private Aggregation API です。

  • ユニークリーチ測定: 多くのコンテンツ プロデューサーや広告主は、自分のコンテンツを見たユニーク ユーザー数を知りたいと考えています。共有ストレージを使用すると、ユーザーが広告、埋め込み動画、パブリケーションを最初に見たタイミングを記録し、同じユーザーが別のサイトで重複してカウントされないようにすることができます。その後、Private Aggregation API を使用してリーチの概要レポートを出力できます。
  • ユーザー属性の測定: コンテンツ制作者は多くの場合、視聴者のユーザー属性を把握します。共有ストレージを使用して、ユーザー属性データが存在する場合は、そのコンテキスト(ファースト パーティ サイトなど)でそのデータを記録し、集計レポートを使用して他の多くのサイト(埋め込みコンテンツなど)でレポートを作成できます。
  • K+ フリークエンシー測定: 「有効フリークエンシー」と呼ばれることもあります。多くの場合、ユーザーが特定のコンテンツを認識または想起するまでに最低限の視聴回数が必要です(多くの場合、広告視聴のコンテキストで)。共有ストレージを使用して、コンテンツを K 回以上表示したユニーク ユーザーのレポートを作成できます。

フィードバックを共有

共有ストレージの提案は現在検討中であり、将来変更される可能性があります。この API をお試しいただき、フィードバックがございましたら、ぜひお寄せください。