prebid / prebid-server

Open-source solution for running real-time advertising auctions in the cloud.
https://prebid.org/product-suite/prebid-server/
Apache License 2.0
434 stars 744 forks source link

General client-side analytics response object #3615

Open bretg opened 7 months ago

bretg commented 7 months ago

The split between server-side and client-side analytics continues to plague us, so adding another in a long line of features aimed at having equivalent analytics functionality. (seatnonbid was the most recent feature in this series.)

As a reminder, the use cases for server-side and client-side analytics are different:

So the aim is to have all relevant data passed to the client from Prebid Server so that client-side analytics can be the one to log the results. This behavior should be turned on the in the request so as not to send extra bytes back when unnecessary.

Here's a proposal:

  1. We've already documented ext.prebid.analytics.ADAPTER as a way for the client to pass arguments through to server-side analytics adapters, so we add a new attribute in a new object ext.prebid.analytics.options.enableclientdetails as a boolean.
  2. In case there are instances where analytics data is sensitive, there should be a control at a host and account level. Add a analytics.allow_client_details boolean configuration that defaults to false.
  3. When creating the client response for the normal ORTB scenario (i.e. not AMP), if the request contains ext.prebid.analytics.options.enableclientdetails: true and config analytics.allow_client_details:false, emit a warning "analytics.options.enableclientdetails not enabled for account" in the response. No metrics or logs.
  4. If the request contains ext.prebid.analytics.options.enableclientdetails: true and config analytics.allow_client_details:true, then PBS-core processes the analytics tags objects into the response at ext.prebid.analytics.tags.
  5. It's the responsibility of the client-side analytics adapters to process this JSON for the module-specific data within.
  6. This does not affect server-side analytics, which proceeds normally.

Example

The "pb-ortb-blocking" module at the "processed auction" stage adds the following Analytics Tags (from the ORTB2 blocking module)

[{
   activities: [{
    name: "enforce-blocking",
    status: "success",
    results: [{
        status: "success-block",
        values: {
                  "attributes": ["badv"],
                  "adomain": ["bad.com"]
        },
        appliedto: {
          "bidder": "bidderA",
           impids: ["1"]
        }
    },{
        status: "success-allow",
        appliedto: {
          "bidder": "bidderA",
          "impids": ["2","3","4"]
        }
    }]
 }]

The "vendorA-brand-safety" module at the "all processed bid responses" stage adds these ATags:

[{
   activities: [{
    name: "brand-safety",
    status: "success",
    results: [{
        status: "success-allow",
        appliedto: {
          "bidder": "bidderA",
          "impids": ["1,","2","3","4"]
        }
    }]
 }]

The resulting response with the request ext.prebid.analytics.options.enableclientdetails: true and config analytics.options.enableclientdetails:true would be

ext.prebid.analytics.tags: [{
  "stage": "processed-auction-request",
  "module": "pb-ortb-blocking",
  "analyticstags": [{
     activities: [{
      name: "enforce-blocking",
      status: "success",
      results: [{
        status: "success-block",
        values: {
                  "attributes": ["badv"],
                  "adomain": ["bad.com"]
        },
        appliedto: {
          "bidder": "bidderA",
           impids: ["1"]
        }
    },{
        status: "success-allow",
        appliedto: {
          "bidder": "bidderA",
          "impids": ["2","3","4"]
        }
    }]
 }]
},{
  "stage": "all-processed-bid-responses",
  "module": "vendorA-brand-safety",
  "analyticstags": [{
   activities: [{
    name: "brand-safety",
    status: "success",
    results: [{
        status: "success-allow",
        appliedto: {
          "bidder": "bidderA",
          "impids": ["1,","2","3","4"]
        }
    }]
}]
bsardo commented 6 months ago

@bretg the behavior here seems reasonable and complete. The only nitpick is whether the response should contain ext.prebid.analyticstags or if it should be ext.prebid.analytics.tags if we want to leave the door open to add additional analytics fields on ext.prebid.analytics.

bretg commented 6 months ago

Thanks - @bsardo . Agree that ext.prebid.analytics.tags leaves the door open for future additions. Changed.

bretg commented 5 months ago

released with PBS-Java 3.3