[UA] Creating custom dimensions and updating your tracking code [Legacy]

Add attributes for your business vertical.
You are viewing a legacy article about Universal Analytics. Learn more about Google Analytics 4 replacing Universal Analytics.

To make the vertical-attribute information available to Analytics, you need to do two things:

  1. Create a custom dimension for each attribute
  2. Update your Analytics tracking code for each relevant web page or app screen to collect data for each attribute

When you enable Remarketing and Advertising Reporting Features, Analytics collects the information it normally does, as well as information from advertising cookies and mobile-advertising IDs when they're present.

When your users view content tagged with vertical attributes (for example, an ad for a specific shoe), then that information is passed to Analytics as custom dimensions. Analytics in turn makes that information available to your Google Ads dynamic remarketing campaign.

For example, if you update your Analytics tracking code to include the Retail attribute ecomm_prodid, then when users view those products, the product IDs are collected in Analytics and passed on to Google Ads. When those users later visit other sites on the Google Display Network, your remarketing campaign has the information it needs to show remarketing ads for those specific products.

Add attributes for your vertical

Each of the following sections includes the required and optional attributes for each vertical, along with examples of the custom dimensions you need to create in Analytics, and examples of how to modify your existing Analytics tracking code to include those attributes.

If you haven't already added the Analytics tracking code to your site or app, do that first.

When you update the tracking code on your website to add vertical attributes, add the code for the attributes just before the closing </head> tag.
Add attributes for the Retail vertical

[Required] ecomm_prodid: The Product ID must match any of the three attributes in the Google Merchant Center feed: id, item_group_id, c:drid This allows the dynamic ad to show users the exact product(s) they viewed.

[Optional] ecomm_pagetype: Indicates which page the user is on. Use this to create list strategies to remarket to users anywhere in the purchase funnel. Pass in one of the example values depending on page type, for example, home, category, product, cart, purchase.

[Optional] ecomm_totalvalue: The total value of the product(s) viewed on your site. Please specify the total value (summing up the values of products viewed on a page).

Custom Dimensions in Analytics

Screenshot showing custom dimensions for ecommerce vertical of dynamic remarketing
Figure 1: Ecommerce custom dimensions.

Code sample for Retail vertical

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','12345, 678910, 98765'); // REQUIRED Product ID value, e.g., 12345, 67890
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, cart, purchase
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga('send', 'pageview');

</script>

Add attributes for the Education vertical

[Required] edu_pid: The Program ID must match values from the Program ID column in your feed. This allows the dynamic ad to show users the exact program(s) they viewed on your site.

[Optional] edu_pagetype: Indicates which page the user is on. Use this to create list strategies to remarket to users anywhere in the purchase funnel. Pass in one of the example values depending on page type, for example, home, searchresults, program, lead, complete.

[Optional] edu_totalvalue: The total value of the program(s) viewed on your site.

[Optional] edu_plocid: If the Location ID is used, the Program ID and Location ID must match values from the Location ID and Program ID columns for a given item in your feed. This is an optional key. This allows the dynamic ad to show users the exact program and location they viewed on your site.

Custom dimensions in Analytics

Screenshot showing custom dimensions for education vertical of dynamic remarketing
Figure 2: Education custom dimensions.

Code sample for Education vertical

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','12345'); // REQUIRED Program ID value, e.g., 12345, 67890
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, lead, complete
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga(‘set’,’dimension4’, ‘Phoenix, AZ’); // Optional Program location ID value, e.g., Austin, TX
  ga('send', 'pageview');

</script>

Add attributes for the Flights vertical

[Required] flight_destid: The Destination ID must match values from the Destination ID column in your feed. This allows the dynamic ad to show users the exact destination(s) they viewed on your site.

[Optional] flight_pagetype: Indicates which page the user is on. Use this to create list strategies to remarket to users anywhere in the purchase funnel. Pass in one of the example values depending on page type, for example, home, searchresults, offerdetail, cart, purchase.

[Optional] flight_totalvalue: The total value of the flight(s) viewed on your site. Please specify the total value (summing up the values of flights viewed on a page).

[Optional] flight_originid: If the Origin ID is used, the Destination ID and Origin ID must match values from the Destination ID and Origin ID columns for a given item in your feed. This is an optional key. This allows the dynamic ad to show users the exact origin and destination they viewed on your site.

[Optional] flight_startdate: Indicates the flight start date (in YYYY-MM-DD format) of the reservation. This allows the dynamic ad to show users the most relevant flight based on the exact start date(s) they viewed on your site.

[Optional] flight_enddate: Indicates the flight end date (in YYYY-MM-DD format) of the reservation. This allows the dynamic ad to show users the most relevant flight based on the exact end date(s) they viewed on your site.

Custom Dimensions in Analytics

Screenshot showing custom dimensions for education vertical of dynamic remarketing
Figure 3: Flights custom dimensions.

Code sample for Flights vertical

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','JFK'); // REQUIRED Flight destination ID value, e.g., SFO, EWR
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, searchresults
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga(‘set’,’dimension4’,‘LAX’); // Optional Flight start origin ID value
  ga(‘set’,’dimension5’,‘2014-10-02’); // Optional Flight start date value, in YYYY-MM-DD format
  ga(‘set’,’dimension6’,‘2014-10-08’); // Optional Flight end date value in YYYY-MM-DD format
  ga('send', 'pageview');

</script>
Add attributes for the Hotels and rentals vertical

[Required] hrental_id: Property ID must match values from the Property ID column in your feed. This allows the dynamic ad to show people the exact hotel(s) or rental(s) they viewed.

[Optional] hrental_pagetype: Page Type indicates which page people visited. Standard values used for automatic list creation are: home, searchresults, offerdetail, conversionintent, and conversion.

[Optional] hrental_totalvalue: The total value of the hotel(s) and rental(s) viewed on your site. Please specify the total value (summing up the values of items viewed on a page).

[Optional] hrental_startdate: The start date (in YYYY-MM-DD format) of the Hotel or Rental viewed on your site.

[Optional] hrental_enddate: The end date (in YYYY-MM-DD format) of the Hotel or Rental viewed on your site.

Custom Dimensions in Analytics

Screenshot showing custom dimensions for hotels and rentals vertical of dynamic remarketing
Figure 4: Hotels and rentals custom dimensions.

Code sample for Hotels-and-rentals vertical

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','1234'); // REQUIRED Hotel Property ID value, e.g., 1234, H256
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, searchresults
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga(‘set’,’dimension4’,’2014-10-02’); // Optional Reservation start Date value
  ga(‘set’,’dimension5’,‘2014-10-08’); // Optional Reservation end Date value
  ga('send', 'pageview');

</script>

Add attributes for the Jobs vertical

<[Required] job_id: The Job ID must match values from the Job ID column in your feed. This allows the dynamic ad to show users the exact job(s) they viewed on your site.

[Optional] job_pagetype: Page Type indicates which page people visited. Standard values used for automatic list creation are: home, searchresults, offerdetail, conversionintent, and conversion.

[Optional] job_totalvalue: The total value of the jobs viewed on your site.

[Optional] job_locid: If the Location ID is used, the Job ID and Location ID must match values from the Job ID and Location ID columns for a given item in your feed. This is an optional key. This allows the dynamic ad to show users the exact job and location they viewed on your site.

Custom Dimensions in Analytics

Screenshot showing custom dimensions for jobs vertical of dynamic remarketing
Figure 5: Jobs custom dimensions.

Code sample for Jobs vertical


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','12345'); // REQUIRED Job ID value, e.g., 12345, 67890
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, searchresults
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga(‘set’,’dimension4’, ‘Phoenix, AZ’); // Optional Job location ID value, e.g., Ann Arbor, MI
  ga('send', 'pageview');

</script>

Add attributes for the Local deals vertical

[Required] local_id: The Deal ID must match values from the Deal ID column in your feed. This allows the dynamic ad to show users the exact local deal(s) they viewed on your site.

[Optional] local_pagetype: Page Type indicates which page people visited. Standard values used for automatic list creation are: home, searchresults, offerdetail, conversionintent, and conversion.

[Optional] local_totalvalue: The total value of the local deal(s) viewed on your site. Please specify the total value (summing up the values of local deals viewed on a page).

Custom dimensions in Analytics

Screenshot showing custom dimensions for local deals vertical of dynamic remarketing
Figure 6: Local deals custom dimensions.

Code sample for Local deals vertical


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','12345'); // REQUIRED Deal ID value, e.g., 12345, 67890
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, searchresults
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga('send', 'pageview');

</script>

Add attributes for the Real estate vertical

[Required] listing_id: The Listing ID must match values from the Listing ID column in your feed. This allows the dynamic ad to show users the exact listing(s) they viewed on your site.

[Optional] listing_pagetype: Page Type indicates which page people visited. Standard values used for automatic list creation are: home, searchresults, offerdetail, conversionintent, and conversion.

[Optional] listing_totalvalue: The total value of the listings viewed on your site.

Custom Dimensions in Analytics

Screenshot showing custom dimensions for real estate vertical of dynamic remarketing
Figure 7: Real estate custom dimensions.

Code sample for Real estate vertical


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','12345'); // REQUIRED Listing ID value, e.g., 12345, 67890
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, searchresults
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga('send', 'pageview');

</script>

Add attributes for the Travel vertical

[Required] travel_destid: The Destination ID must match values from the Destination ID column in your feed. This is a required key. This allows the dynamic ad to show users the exact destination(s) they viewed on your site.

[Optional] travel_pagetype: Page Type indicates which page people visited. Standard values used for automatic list creation are: home, searchresults, offerdetail, conversionintent, and conversion.

[Optional] travel_totalvalue: The total value of the offer(s) viewed on your site. Please specify the total value (summing up the values of offers viewed on a page).

[Optional] travel_originid: If the Origin ID is used, the Destination ID and Origin ID must match values from the Destination ID and Origin ID columns for a given item in your feed. This is an optional key. This allows the dynamic ad to show users the exact destination and origin they viewed on your site.

[Optional] travel_startdate: Indicates the travel start date (in YYYY-MM-DD format) of the reservation. This allows the dynamic ad to show users offers with the exact start date(s) they viewed on your site.

[Optional] travel_enddate: Indicates the travel end date (in YYYY-MM-DD format) of the reservation. This allows the dynamic ad to show users offers with the exact end date(s) they viewed on your site.

Custom Dimensions in Analytics

Screenshot showing custom dimensions for travel vertical of dynamic remarketing
Figure 8: Travel custom dimensions.

Code sample for Travel vertical


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','NYC'); // REQUIRED Destination ID value, e.g., NYC, SFO
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, searchresults
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga('set','dimension4','SFO'); // Optional Origin ID value, e.g., FTW, CHI
  ga(‘set’,’dimension5’,’2014-10-02’); // Optional Reservation start date value
  ga(‘set’,’dimension6’,‘2014-10-08’); // Optional Reservation end date value
  ga('send', 'pageview');

</script>

Add attributes for the Custom vertical

[Required] dynx_itemid: The ID must match values from the ID column in your feed. This allows the dynamic ad to show users the exact item(s) they viewed on your site.

[Optional] dynx_pagetype: Indicates which page the user is on. Use this to create list strategies to remarket to users anywhere in the purchase funnel. Pass in one of the example values depending on page type, for example, home, searchresults, offerintent, conversionintent, conversion.

[Optional] dynx_totalvalue: The total value of the item(s) viewed on your site. Please specify the total value (summing up the values of items viewed on a page).

[Optional] dynx_itemid2: If ID2 is used, the ID2 must match values from the ID2 column for a given item in your feed. This is an optional key. This allows the dynamic ad to show users the exact Item ID and Item ID 2 combination they viewed on your site.

Custom Dimensions in Analytics

Screenshot showing custom dimensions for custom vertical of dynamic remarketing
Figure 9: Custom dimensions for dynamic remarketing.

Code sample for Custom vertical


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-YY', 'auto'); // Insert your GA Web Property ID here, e.g., UA-12345-1
  ga('set','dimension1','12345'); // REQUIRED Item ID value, e.g., 12345, 67890
  ga('set','dimension2',’searchresults’); // Optional Page type value, e.g., home, searchresults
  ga('set','dimension3','99.95'); // Optional Total value, e.g., 99.95, 5.00, 1500.00
  ga(‘set’,’dimension4’, ‘Phoenix, AZ’); // Optional Item ID2 value
  ga('send', 'pageview');

</script>

If you are going to update your tags in Tag Manager, follow these instructions.

Next steps

  1. Create Remarketing Audiences in Analytics.
  2. Create attributes for Dynamic Remarketing.
  3. Create your Dynamic Remarketing campaign in Google Ads.

Related resources

Custom dimensions and metrics

Working with custom dimensions in Google Tag Manager

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
10415541717939161810
true
Search Help Center
true
true
true
true
true
69256
false
false