Using Floodlight data

The following sample scripts use Floodlight data to inform their custom bidding algorithm:

Sales revenue Floodlight tag

You can create a custom bidding script that optimizes towards sales revenue tracked by Floodlight Sales tag using total_conversion_value.

Real-world example
An e-commerce advertiser wants to optimize for transaction value (instead of total transactions). You are tracking the checkout confirmation with a Floodlight Sales tag, and a transaction value.

Sample script

The following script returns the value tracked in a Floodlight Sales tag:
  • Floodlight_ID: Specify your activity ID.
  • model_id:
    • If you've set up an attribution model at the advertiser level, specify your Attribution Model ID.
    • If not, specify 0 to use last-touch attribution.
return (total_conversion_value(Floodlight_ID, model_id))

Weighted conversions using a combination of Floodlights

You can optimize to 3 different conversions activities, where each activity is worth a different value using the sum_aggregate to sum the value of multiple conversions:

  • If an impression leads to different conversions: The values of conversions are summed when attributing value to the impression.
  • If an impression leads to multiple conversions for the same activity ID: The number of conversions are summed and then multiplied by the conversion weighting.
Real-world examples
  • A car manufacturer is tracking conversions on minivan, SUV, and sedan product pages. To optimize toward value, each category is assigned different values.
  • A nonprofit wants to optimize for donation events since donation events are rare. They can add upper-funnel activities and assign lower weights to them to drive volume. For example, clicks on “Learn more about the organization” and “See how you can help”.

Sample script

The following script returns 3 different conversions activities, where each activity has a different value using sum_aggregate:
  • Floodlight_ID1, Floodlight_ID2, Floodlight_ID3: Specify your activity IDs. For example: 123456, 456789, 78901.
  • model_id:
    • If you've set up an attribution model at the advertiser level, specify your Attribution Model ID.
    • If not, specify 0 to use last-touch attribution.
  • weighting_1, weighting_2, weighting_3: Specify a weight for each conversion activity. For example: 100, 5, or 0.2.
return sum_aggregate([
        ([total_conversion_count(Floodlight_ID_1, model_id)>0], total_conversion_count(Floodlight_ID_1, model_id)*weighting_1),
        ([total_conversion_count(Floodlight_ID_2, model_id)>0], total_conversion_count(Floodlight_ID_2, model_id)*weighting_2),
        ([total_conversion_count(Floodlight_ID_3, model_id)>0], total_conversion_count(Floodlight_ID_3, model_id)*weighting_3)
])

Variations to optimizing multiple conversion activities

There are variations to how you can optimize multiple conversions activities.

  • You can change the number of weighted conversion activities by removing or adding new conditions.
  • You can assign the value of the highest-value conversion event by using max_aggregate.
  • To assign the value of the first matching conversion event, based on the order in your script, use first_match_aggregate.

Sample script

The following sample script assigns a higher value to a conversion event, and a lower value to clicks:

return max_aggregate([
    ([click], weight_1),
    ([total_conversion_count(Floodlight_ID_1, model_id)>0], weight_2)])

Sample script

The following sample script assigns a higher value to clickthrough conversion events, and a lower value to a view through conversion events:
return sum_aggregate([
    ([click, total_conversion_count(Floodlight_ID_1, model_id)>0], weight_1),
    ([not click, total_conversion_count(Floodlight_ID_1, model_id)>0], weight_2)])

Custom Floodlight variables

You can create a script that optimizes toward a single custom Floodlight variable for a single floodlight activity using conversion_custom_variable.

When using u-variables in custom bidding scripts, they must be shared with Display & Video 360 first:

  1. Navigate to Resources > Floodlight Group.
  2. Select a Floodlight activity.
  3. For Custom Floodlight variables, choose the view icon.
  4. Check the box next to the u-variable.

Real-world example

A car-rental chain wants to optimize for the number of vehicle reservations. The reservation confirmation activity is tracked in a Floodlight, and the number of nights booked in a Custom Floodlight variable.

Sample script

The following script example optimizes to a single custom Floodlight variable for a single Floodlight activity. The script returns a string if there's a conversion or None if there's no conversion. All non-converting impressions as valued as 0. Any impression that is not attributed by the model will return as None and be valued as 0:

  • Floodlight_ID: Specify your activity ID.
  • model_id:
    • If you've set up an attribution model at the advertiser level, specify your Attribution Model ID.
    • If not, specify 0 to use last-touch attribution.
  • u_variable_index: Specify the Custom Floodlight u-variable index for your activity ID.

_uvar = conversion_custom_variable(Floodlight_ID, model_id, u_variable_index)

if _uvar != None and _uvar != "":
    return float(_uvar)

return 0

Was this helpful?

How can we improve it?

Need more help?

Try these next steps:

true
2024 Privacy Readiness guide

Prepare for a world without third-party cookies and unlock the AI
opportunity by adopting the right durable audience and measurement
solutions.
Start Today

Search
Clear search
Close search
Google apps
Main menu