Using data from Google Analytics

The following sample scripts use data from Google Analytics 4 and Google Analytics 360 to inform their custom bidding algorithm.

  1. Google Analytics 4 sample scripts:
  2. Google Analytics 360 sample scripts:

Google Analytics 4

Prerequisite

Before you can use Google Analytics goals or conversions for automatic bidding, you must first link your Google Analytics 4 property to Display & Video 360.

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 towards users that trigger certain events. You can track conversion events using different pixels.

Sample script

Using the following Activity ID and Floodlight location, the following sample script optimizes towards 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 towards a transaction value

You can optimize towards 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

Prerequisite

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

  1. Link your Google Analytics 360 account with the Display & Video 360 advertiser.
  2. Create goals within the Google Analytics 360 account.
When you link your Google Analytics 360 account with Display & Video 360, you are sharing conversion data. This conversion data will only be available in Display & Video 360 through custom bidding metrics reporting.
 
Make sure the linked accounts are both sharing data and have goals setup. Scripts not using Google Analytics 360 goals will not score impressions.

You can use Google Analytics goals on your website to inform your bidding strategy. Since Google Analytics 360 goals require clicks, there must be sufficient data to generate a model. You can verify the volume of data by pulling a report in Google Analytics 360.

To view the volume of goal events based on the last non-direct click model within Google Analytics:

  1. In Google Analytics 360, go to: Acquisition > All Traffic > Source/Medium report.
  2. Choose the filter for dbm / cpm.

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, it will return 1.
  • If false, it will return 0.

return has_ga_goal(GA View ID, GA Goal ID)

Using weighted conversions

You can optimize towards 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 towards 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 towards the most valuable user behavior.

Sample script

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

  • has_ga_goal(111, 222): Customer spend 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 user who spends 5 minutes on a page and makes a purchase is scored more valuable than the user who spends 5 minutes on a page and views 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?

Sign in for additional support options to quickly solve your issue

Search
Clear search
Close search
Google apps
Main menu
Search Help Center
true
true
true
true
69621
false
false