Using data from Google Analytics

You can use Google Analytics 4 to inform your custom bidding strategy. This topic provides information about prerequisites to using Google Analytics with Display & Video 360 and sample scripts using data from Google Analytics 4.

Topics in this article

Prerequisite

To use Google Analytics with Display & Video 360 for custom bidding, you must:

  1. Link your Google Analytics account to Display & Video 360 to make sure that both accounts are sharing data.
  2. If you haven't yet, create a goal in Google Analytics.

There must be sufficient conversion data to inform your custom bidding strategy for your script to score impressions.You can verify the volume of data by generating a report based on the last non-direct click model in Google Analytics:

For Google Analytics 4:

  1. Go to: Acquisition and then Traffic Acquisition and then Session Source/Medium.
  2. Choose the filter for dbm / cpm.
When you link Google Analytics with Display & Video 360, you're sharing conversion data. This conversion data is only available in Display & Video 360 through custom bidding metrics reporting.

Google Analytics 4 sample scripts

Using weighted conversions

You can optimize toward your most valuable conversions by using weighted conversions.

Sample script

Given 3 conversion types: a newsletter sign-up, a one-time purchase, and a subscription purchase.

The following sample script assigns the following conversion values:

  • Subscription purchase has a weight of 10. (most-valued conversion)
  • Newsletter sign-up has a weight of 2.
  • One-time purchase has a weight of 1. (least-valued conversion)

return sum_aggregate([

  ([ga4_conversions_count(123, 456)>0], 1),    #one-time purchase

  ([ga4_conversions_count(124, 456)>0], 2),    #newsletter sign-up

  ([ga4_conversions_count(125, 457)>0)], 10)   #subscription purchase

])

Weighted conversion using a combination of Google Analytics events

You can score ad impressions that lead to different conversion events to optimize toward users that trigger certain events. You can track conversion events using different Floodlight activities.

Sample script

Using the following Activity ID and Floodlight location, the following sample script optimizes toward the most valuable event by using weighted conversions.

Activity ID Floodlight location (event)
123 landing_page
124 application_start
125 application_summary
126 application_complete

return max_aggregate([

  ([ga4_conversions_count(123, “landing_page”)], 1),        #least valued

  ([ga4_conversions_count(124, “application_start”)], 5),   

  ([ga4_conversions_count(125, “application_summary”)], 7),

  ([ga4_conversions_count(126, “application_complete”)], 9)  #most valued

])

Optimizing toward a transaction value

You can optimize toward a specified transaction value by scoring impressions based on the actual value of the purchase to maximize your ROAS using Google Analytics 4 properties.

You can assign a $100 purchase a score of 100, while a $10 purchase scores 10.

return ga4_conversions_total_value(property_id, conversion_event_name)

Google Analytics 360 sample scripts

Using a single Google Analytics 360 goal

You can optimize to users who have spent longer than 30 seconds on a page by setting up a duration goal in Google Analytics 360. You can then use the View ID and Goal ID in a script.

Sample script

For example:

  • If has_ga_goal(GA View ID, GA Goal ID) returns true, the script returns 1.
  • If false, the script returns 0.

return has_ga_goal(GA View ID, GA Goal ID)

Using weighted conversions

You can optimize toward your most valuable conversions by using weighted conversions. 

Sample script

Given 3 conversion types:

  • a newsletter sign-up
  • a one time purchase
  • a subscription purchase

The following sample script assigns a higher value to conversions leading to a subscription purchase than a newsletter sign-up.

return sum_aggregate([

  ([ga_goals_count(124, 456)>0], 1),    #newsletter

  ([ga_goals_count(125, 457)>0], 10)   #subscription

])

Weighted conversions using a combination of Google Analytics 360 goals

You can optimize for specific user paths on your site using Google Analytics 360 Funnel Destination paths. You can show greater brand affinity by valuing one path twice as much as others.

Sample script

The first Google Analytics Goal GA View ID, GA Goal ID (111,222) is equal to half the value of the second Google Analytics Goal (333,444).

return sum_aggregate([

        ([has_ga_goal(111, 222)], ga_goals_count(111, 222)),

        ([has_ga_goal(333, 444)], ga_goals_count(333, 444)*2)

])

Optimizing toward the most valuable user behavior

Since Google Analytics 360 helps you understand the behavior of valuable customers, you can use this data in custom bidding to optimize toward the most valuable user behavior.

Sample script

The following sample script optimizes toward the most valuable user behavior by scoring users based on a sum of different Google analytics goals:

  • has_ga_goal(111, 222): Customer spends at least 5 minutes on a page. 
  • has_ga_goal(333, 444): Customer view at least 7 pages.
  • has_ga_goal(555, 666): Customer makes a purchase

The customer who "spends at least 5 minutes on a page" and "makes a purchase" is scored more than the customer who "spends at least 5 minutes on a page" and "views at least 7 pages".

return sum_aggregate([

  ([has_ga_goal(111, 222)], ga_goals_count(111, 222)),

  ([has_ga_goal(333, 444)], ga_goals_count(333, 444)),

  ([has_ga_goal(555, 666)], ga_goals_count(555, 666)*5)

])

Maximizing return on ad spend

You can maximize the return on ad spend (ROAS) from users visiting more than 5 pages per session using a Google Analytics 360 session goal. Since keen clients are more likely to return, you still want to maximize your ROAS.

For example:

if ga_goals_count(111, 222)>5:

 return ga_goals_total_value(111, 222)

else:

 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
Main menu
3887487357470467880
true
Search Help Center
true
true
true
true
true
69621
false
false