- [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SCHEMA_REPRESENTATION)
- [Ruleset](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Ruleset)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Ruleset.SCHEMA_REPRESENTATION)
- [Rule](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Rule)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Rule.SCHEMA_REPRESENTATION)
- [RuleCondition](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#RuleCondition)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#RuleCondition.SCHEMA_REPRESENTATION)
- [SignalComparison](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalComparison)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalComparison.SCHEMA_REPRESENTATION)
- [Signal](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Signal)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Signal.SCHEMA_REPRESENTATION)
- [ComparisonValue](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#ComparisonValue)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#ComparisonValue.SCHEMA_REPRESENTATION)
- [DayAndTime](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#DayAndTime)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#DayAndTime.SCHEMA_REPRESENTATION)
- [SignalValue](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalValue)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalValue.SCHEMA_REPRESENTATION)
- [FloodlightActivityConversionSignal](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#FloodlightActivityConversionSignal)
  - [JSON representation](https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#FloodlightActivityConversionSignal.SCHEMA_REPRESENTATION)

Rule-based algorithm.

| JSON representation |
|---|
| ``` { "impressionSignalRuleset": { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Ruleset`) }, "postImpressionSignalRuleset": { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Ruleset`) }, "attributionModelId": string } ``` |

| Fields ||
|---|---|
| `impressionSignalRuleset` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Ruleset`)`` Rules for the impression signals. |
| `postImpressionSignalRuleset` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Ruleset`)`` Rules for the post-impression signals. This field is only supported for allowlisted partners. |
| `attributionModelId` | `string (https://developers.google.com/discovery/v1/type-format format)` Attribution model for the algorithm. This field is only supported for allowlisted partners. |

## Ruleset

A ruleset consisting of a list of rules and how to aggregate the resulting values.

| JSON representation |
|---|
| ``` { "rules": [ { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Rule`) } ], "aggregationType": enum (`https://developers.google.com/display-video/api/reference/rest/v4/RuleAggregationType`), "maxValue": number } ``` |

| Fields ||
|---|---|
| `rules[]` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Rule`)`` List of rules to generate the impression value. |
| `aggregationType` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/RuleAggregationType`)`` How to aggregate values of evaluated rules. |
| `maxValue` | `number` Maximum value the ruleset can evaluate to. |

## Rule

Set of conditions.

The return value of the rule is either:

- The return value for single met condition or
- The defined default return value if no conditions are met.

| JSON representation |
|---|
| ``` { "conditions": [ { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#RuleCondition`) } ], "defaultReturnValue": { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalValue`) } } ``` |

| Fields ||
|---|---|
| `conditions[]` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#RuleCondition`)`` List of conditions in this rule. The criteria among conditions should be mutually exclusive. |
| `defaultReturnValue` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalValue`)`` The default return value applied when none of the conditions are met. |

## RuleCondition

Set of signal comparisons. Equivalent of an `if` statement.

| JSON representation |
|---|
| ``` { "signalComparisons": [ { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalComparison`) } ], "returnValue": { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalValue`) } } ``` |

| Fields ||
|---|---|
| `signalComparisons[]` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalComparison`)`` List of comparisons that build `if` statement condition. The comparisons are combined into a single condition with `AND` logical operators. |
| `returnValue` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#SignalValue`)`` The value returned if the `signalComparisons` condition evaluates to `TRUE`. |

## SignalComparison

A single comparison. The comparison compares the `signal` to the `comparisonValue`.

The comparison of `siteId==123` is represented with the following field values:

- `signal` has an `impressionSignal` of `SITE_ID`.
- `comparisonOperator` is set to `EQUAL`.
- `comparisonValue` is set to 123.

| JSON representation |
|---|
| ``` { "signal": { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Signal`) }, "comparisonOperator": enum (`https://developers.google.com/display-video/api/reference/rest/v4/ComparisonOperator`), "comparisonValue": { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#ComparisonValue`) } } ``` |

| Fields ||
|---|---|
| `signal` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#Signal`)`` Signal to compare. |
| `comparisonOperator` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/ComparisonOperator`)`` Operator used to compare the two values. In the resulting experession, the `signal` will be the first value and the \`comparisonValue will be the second. |
| `comparisonValue` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#ComparisonValue`)`` Value to compare signal to. |

## Signal

Signal used to evaluate rules.

| JSON representation |
|---|
| ``` { // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "impressionSignal": enum (`https://developers.google.com/display-video/api/reference/rest/v4/ImpressionSignal`), "clickSignal": enum (`https://developers.google.com/display-video/api/reference/rest/v4/ClickSignal`), "activeViewSignal": enum (`https://developers.google.com/display-video/api/reference/rest/v4/ActiveViewSignal`) // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| The signal used to evaluate rules. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `impressionSignal` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/ImpressionSignal`)`` Signal based on impressions. |
| `clickSignal` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/ClickSignal`)`` Signal based on clicks. This field is only supported for allowlisted partners. |
| `activeViewSignal` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/ActiveViewSignal`)`` Signal based on active views. This field is only supported for allowlisted partners. |
| End of mutually exclusive fields. ||

## ComparisonValue

A value to compare the signal to.

| JSON representation |
|---|
| ``` { // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "int64Value": string, "doubleValue": number, "stringValue": string, "boolValue": boolean, "creativeDimensionValue": { object (`https://developers.google.com/display-video/api/reference/rest/v4/Dimensions`) }, "dayAndTimeValue": { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#DayAndTime`) }, "deviceTypeValue": enum (`https://developers.google.com/display-video/api/reference/rest/v4/RuleDeviceType`), "onScreenPositionValue": enum (`https://developers.google.com/display-video/api/reference/rest/v4/OnScreenPosition`), "environmentValue": enum (`https://developers.google.com/display-video/api/reference/rest/v4/Environment`), "exchangeValue": enum (`https://developers.google.com/display-video/api/reference/rest/v4/Exchange`), "contentDurationValue": enum (`https://developers.google.com/display-video/api/reference/rest/v4/ContentDuration`), "contentStreamTypeValue": enum (`https://developers.google.com/display-video/api/reference/rest/v4/ContentStreamType`), "contentGenreIdValue": string, "videoPlayerSizeValue": enum (`https://developers.google.com/display-video/api/reference/rest/v4/VideoPlayerSize`) // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| The value to compare the signal to. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `int64Value` | `string (https://developers.google.com/discovery/v1/type-format format)` Integer value. |
| `doubleValue` | `number` Double value. |
| `stringValue` | `string` String value. |
| `boolValue` | `boolean` Boolean value. |
| `creativeDimensionValue` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/Dimensions`)`` Creative dimension value. |
| `dayAndTimeValue` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#DayAndTime`)`` Day and time value. Only `TIME_ZONE_RESOLUTION_END_USER` is supported. |
| `deviceTypeValue` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/RuleDeviceType`)`` Device type value. |
| `onScreenPositionValue` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/OnScreenPosition`)`` Ad position value. |
| `environmentValue` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/Environment`)`` Environment value. |
| `exchangeValue` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/Exchange`)`` Exchange value. |
| `contentDurationValue` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/ContentDuration`)`` Video content duration value. |
| `contentStreamTypeValue` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/ContentStreamType`)`` Video delivery type value. |
| `contentGenreIdValue` | `string (https://developers.google.com/discovery/v1/type-format format)` Video genre id value. |
| `videoPlayerSizeValue` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/VideoPlayerSize`)`` Video player size value. This field is only supported for allowlisted partners. |
| End of mutually exclusive fields. ||

## DayAndTime

Representation of time defined by day of the week and hour of the day.

| JSON representation |
|---|
| ``` { "dayOfWeek": enum (`https://developers.google.com/display-video/api/reference/rest/v4/advertisers.adGroups.targetingTypes.assignedTargetingOptions#AssignedTargetingOption.DayOfWeek`), "hourOfDay": integer, "timeZoneResolution": enum (`https://developers.google.com/display-video/api/reference/rest/v4/advertisers.adGroups.targetingTypes.assignedTargetingOptions#AssignedTargetingOption.TimeZoneResolution`) } ``` |

| Fields ||
|---|---|
| `dayOfWeek` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/advertisers.adGroups.targetingTypes.assignedTargetingOptions#AssignedTargetingOption.DayOfWeek`)`` Required. Day of the week. |
| `hourOfDay` | `integer` Required. Hour of the day. |
| `timeZoneResolution` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/advertisers.adGroups.targetingTypes.assignedTargetingOptions#AssignedTargetingOption.TimeZoneResolution`)`` Required. The mechanism used to determine the relevant timezone. |

## SignalValue

Adjusted value of the signal used for rule evaluation.

| JSON representation |
|---|
| ``` { // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "activeViewSignal": enum (`https://developers.google.com/display-video/api/reference/rest/v4/ActiveViewSignal`), "floodlightActivityConversionSignal": { object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#FloodlightActivityConversionSignal`) } // End of mutually exclusive fields. "number": number } ``` |

| Fields ||
|---|---|
| The base signal used to generate the value. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `activeViewSignal` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/ActiveViewSignal`)`` Signal based on active views. Only `TIME_ON_SCREEN` is supported. This field is only supported for allowlisted partners. |
| `floodlightActivityConversionSignal` | ``object (`https://developers.google.com/display-video/api/reference/rest/v4/AlgorithmRules#FloodlightActivityConversionSignal`)`` Signal based on floodlight conversion events. This field is only supported for allowlisted partners. |
| End of mutually exclusive fields. ||
| `number` | `number` Value to use as result. |

## FloodlightActivityConversionSignal

The rule to score impressions based on Floodlight conversion events.

| JSON representation |
|---|
| ``` { "floodlightActivityId": string, "countingMethod": enum (`https://developers.google.com/display-video/api/reference/rest/v4/CountingMethod`), "conversionCounting": enum (`https://developers.google.com/display-video/api/reference/rest/v4/ConversionCounting`) } ``` |

| Fields ||
|---|---|
| `floodlightActivityId` | `string (https://developers.google.com/discovery/v1/type-format format)` Required. Id of the floodlight activity. |
| `countingMethod` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/CountingMethod`)`` Required. The way to acquire value from the floodlight activity, for example, count of the conversion. |
| `conversionCounting` | ``enum (`https://developers.google.com/display-video/api/reference/rest/v4/ConversionCounting`)`` Required. The type of conversions to be used in impression value computation, for example, post-click conversions. |