Use the Google tag

To ensure that Display & Video 360 can measure your conversions effectively, we recommend that you use the Google tag (gtag.js) as the format for your Floodlight activities.

About the Google tag

The Google tag is a site-wide web tagging library that works across Google’s site and conversion measurement products - giving you better control while making implementation easier.

  • Faster and easier integration with other Google products: The Google tag is not only used by Google Marketing Platform advertising products (Display & Video 360, Search Ads 360, and Campaign Manager 360) but also by other Google products such as Google Ads and Google Analytics. If you use these products, the Google tag makes implementation easier by providing a unified tagging experience.
  • More accurate conversion tracking: Using the Google tag sets new cookies on your domain. This ensures that Google Marketing Platform can measure your conversions more accurately. If you’re using iframe or image tags instead of the Google tag, Google Marketing Platform is not able to observe all of your conversions.
 
Make sure you enable Enhanced attribution when setting up your Floodlight configuration to see the benefits of improved conversion tracking for display and video inventory. Learn how to enable Enhanced attribution

Unsupported environments

  • The Google tag is not intended to work in mobile apps. Learn more about options for using Floodlight with apps.
  • The Google tag doesn’t support Accelerated Mobile Pages (AMP). You should continue to follow the existing process for using Floodlight with AMP.
  • The Google tag won’t fire in browsers that don’t support JavaScript. The tag includes a <noscript> section that will load if JavaScript isn’t supported. Learn more below

Cookies set by the Google tag

When using the Google tag for Floodlight activities, the tag sets new cookies on your domain, which will store a unique identifier for a user or the ad click that brought the user to your site.

  • Search Ads 360: The cookies receive the ad click information from a GCLID (“Google Click Identifier”) parameter that Search Ads 360 adds to the landing page URL just before redirecting users to your site.
  • Display & Video 360 and Campaign Manager 360: The cookies receive the ad click information from a DCLID (“DoubleClick Click Identifier”) parameter that Display & Video 360 and Campaign Manager 360 adds to the landing page URL just before redirecting users to your site.

If you don’t want the Google tag to set first-party cookies on your site’s domain, you can opt out by adding the highlighted portion below to your global snippet’s config command:

gtag('config', 'DC-1234567', {'conversion_linker': false});

We don’t recommend doing this as it will lead to less accurate conversion measurement.

Since the Google tag is able to use information from new cookies that are set on your domain, please ensure that you’re providing users with clear and comprehensive information about data collection, and obtaining consent where legally required.

Collection of remarketing data by Google tag

Once you set up the Google Ads tag for standard remarketing or dynamic remarketing, the Google tag, and an optional event snippet can be deployed site-wide to track specific remarketing events.

You can choose to disable the collection of remarketing data for users who do not wish to view personalized ads using the parameter: allow_ad_personalization_signals. This parameter will let you disable the usage of the data for personalized ads and the default value of the parameter will be set to true. When you set the parameter’s value to false, it will disable the usage of the data for personalized ads.

If you don’t want the Google tag to collect remarketing data, add the highlighted gtag('set') command to your Google tag above the gtag('js') command:

<!--

Start of global snippet: Please do not remove

Place this snippet between the <head> and </head> tags on every page of your site.

-->

<!-- Google tag (gtag.js) - Google Marketing Platform -->

<script async src="https://www.googletagmanager.com/gtag/js?id=DC-[floodlightConfigID]"></script>

<script>

 window.dataLayer = window.dataLayer || [];

 function gtag(){dataLayer.push(arguments);}

 gtag('set', 'allow_ad_personalization_signals', false);

 gtag('js', new Date());

 

 gtag('config', 'DC-[floodlightConfigID]');

</script>

<!-- End of global snippet: Please do not remove -->

 

Implement the Google tag

A Google tag is made up of two snippets of JavaScript: a global snippet and an event snippet. Insert the Google tag between the <head> and </head> tags on every page of your site. The global snippet is placed on all pages, and the event snippet is additionally placed on pages with events you’re tracking. Website administrators will need to pass values into certain fields in the Google tag.

Step 1: Add the global snippet to every page of your site

The global snippet should be placed on every page of your site between the <head> and </head> tags. After you’ve installed a global snippet on every page of your site, you don’t need to add the global snippet again. If you’ve already installed a global snippet for another Google product, or for another Floodlight configuration, follow the instructions below to modify the global snippet for multiple products.

Here's an example of a global snippet:

<!-- 
Start of global snippet: Please do not remove
Place this snippet between the <head> and </head> tags on every page of your site.
-->
<!-- Google tag (gtag.js) - DoubleClick -->
<script async src="https://www.googletagmanager.com/gtag/js?id=DC-[floodlightConfigID]"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'DC-[floodlightConfigID]');
</script>
<!-- End of global snippet: Please do not remove -->

Step 2: Add the event snippet to pages with events you're tracking

The event snippet should be placed on pages with events you’re tracking. This could be to track conversion events or to add users to audience lists. It can be placed anywhere on the page after the global snippet, but we recommend also placing it within the <head> section for the best tracking accuracy.

The fields in the event snippet are different depending on the tag type, counting method, and other data you’re passing into the tag. See the section below for detailed information about the fields in an event snippet.

Here's an example of an event snippet:

<!-- 
Event snippet for Activity Name on http://foo.com: Please do not remove.
Place this snippet on pages with events you’re tracking.
Creation date: 10/30/2017
-->
<script>
  gtag('event', 'conversion', {
    'allow_custom_scripts': true,
    'u1': '[variable]',
    'send_to': 'DC-[floodlightConfigID]/[activityGroupTagString]/[activityTagString]+[countingMethod]'
  });
</script>
<noscript>
<img src="https://ad.doubleclick.net/ddm/activity/src=[floodlightConfigID];type=[activityGroupTagString];cat=[activityTagString];dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?" width="1" height="1" alt=""/>
</noscript>
<!-- End of event snippet: Please do not remove -->

Passing data to fields in the Google tag

If you’re migrating from iframe or image tags to the Google tag, see our retagging guide to learn more about how parameters from these tags map to fields in the Google tag.

Fields in the global snippet

The global snippet loads the Google tag’s tracking library and configures the accounts where the tag sends data.

Let’s take a closer look at some key fields in the global snippet:

  • src="https://www.googletagmanager.com/gtag/js?id=DC-12345678"
    This section shows a unique identifier for Floodlight activity configuration where the tag was originally generated.

  • gtag('config', 'DC-[12345678]')
    The config command shows the specific Floodlight activity configuration associated with the Google tag.

If you’re using the Google tag with multiple Google products, you may see multiple config commands and differing IDs in the src= string. See the section below for more details.

You should not dynamically pass data into the fields in the global snippet. Once it’s installed on your site with the correct account identifiers, the global snippet is complete.

Fields in the event snippet - overview

The event snippet is specific to each Floodlight activity and the corresponding event it’s tracking. Some fields are common to all event snippets, while other fields depend on the settings of the Floodlight activity associated with the tag.

You’ll need to dynamically pass data to fields in the event snippet. Here’s an overview of the key fields in event snippets. See the sections below for more detailed information about each field.

Field name Value format Floodlight activity type Overview
allow_custom_scripts Boolean All This should always be set to true.
u1, u2, etc. String All Indicates custom variables.
send_to String All Maps routing identifiers for the Floodlight activity.
value Number Sales-data enabled Passes the revenue generated by a transaction.
transaction_id Number Sales-data enabled Sets a unique identifier for a transaction.
quantity Number Sales-data enabled Contains the number of items sold during a transaction.

Fields in all event snippets

The following fields appear in all event snippets generated by Display & Video 360:

  • 'allow_custom_scripts': true
    This field must be set to true. Campaign Manager 360 users can learn more about using this field here.

  • 'send_to'
    The send_to field contains routing identifiers for the Floodlight activity that correspond to the 'src=', 'type=', and 'cat=' parameters of iframe and image tags. 

  • 'u1': '[variable]'
    Custom variables can accept any values that you choose to pass to them. You can use these values to build audience lists. You must not pass any data that Google Marketing Platform could use or recognize as personally-identifiable information. 

Fields in event snippets for sales-data enabled Floodlight activities

Sales-data enabled Floodlight activities are usually placed on the confirmation page following a sale, with information about the sale passed to the tag. There are a few fields specific to sales-enabled Floodlight activities:

  • 'value': '[Revenue]'
    Use this field to pass the revenue generated by a transaction—in other words, the purchase price of the items in the sale. In most cases, the value is the revenue generated, not the total purchase price, which might include sales tax, VAT, or shipping costs. The field accepts numbers without commas or currency symbols; you can use a decimal point (.) if desired. This corresponds to the cost= parameter in iframe and image tags.

  • 'transaction_id': '[OrderID]'
    Use this field to insert a unique numerical identifier for each transaction. This corresponds to the ord= parameter in iframe and image tags.

  • 'quantity': '[Quantity]'
    Use this field to pass the number of items sold during a transaction:

    If you're counting each transaction as a single conversion, the value is 1.

    If you're counting each item sold during a single transaction as a separate conversion, insert the number of items sold as part of each transaction as the value.

    The value must be an integer greater than zero. Display & Video 360 multiplies the value by the number of conversion events to get the number of conversions for sales-enabled Floodlight activities. If the value is zero, or the field contains a non-numeric value, no conversions will be counted.

Custom fields

You can insert custom data into event snippets with the dc_custom_params field.

This field accepts any values you want to pass to Google Marketing Platform. You must not pass any data that Google Marketing Platform could use or recognize as personally-identifiable information. Here are some common fields you may want to use with dc_custom_params field:

Field name Value format Counting method Description
ord Number All The Google tag will automatically handle cache busting for you. If you choose to override this and control cache busting manually, you can use the ord field. Add a value to the ord field based on the tag type and counting method the same way you would for an iframe tag.
num Number Counter - unique The Google tag will automatically handle cache busting for you. If you choose to override this and control cache busting manually, you can use the num field. Add a value to the num field the same way you would for an iframe tag.
dc_lat 0 or 1 All This field applies to tags on mobile devices. It accepts a value of 0 or 1. A value of 1 means that the user has enabled the “Limit Ad Tracking” option for IDFA or AdID in order to opt out of interest-based ads and remarketing. If "Limit Ad Tracking" is off, the value is 0. If missing or unpopulated, this field will default to 0.
tag_for_child_directed_treatment 0 or 1 All This field applies to tags on mobile devices. It accepts a value of 0 or 1. A value of 1 indicates that this particular request may come from a user under the age of 13, under COPPA compliance.
tfua 0 or 1 All It accepts a value of 0 or 1. A value of 1 indicates that this particular request may come from a user under the age of 16 (may differ by country), under compliance with the EU’s General Data Protection Regulation (GDPR) or other regulations.
npa 0 or 1 All It accepts a value of 0 or 1. A value of 1 indicates that this particular request may come from a user who wishes to opt-out of remarketing. If missing or unpopulated, this field will default to 0.
match_id string all

A unique advertiser created identifier (passed via Floodlight) that can be synced with Google to attribute offline conversions.

  • Match ID has a limit of 100 characters and is case sensitive.
  • Match ID can only contain letters, numbers, underscores, hyphens and periods.
 

Example event snippet with the dc_custom_params field

<!-- 
Event snippet for Activity Name on http://foo.com: Please do not remove.
Place this snippet on pages with events you’re tracking. 
Creation date: 10/30/2017
-->
<script>
  gtag('event', 'purchase', {
    'allow_custom_scripts': true,
    'value': '[Revenue]',
    'transaction_id': '[OrderID]',
    'send_to': 'DC-[floodlightConfigID]/[activityGroupTagString]/[activityTagString]+[countingMethod]',
    'dc_custom_params': {
      'ord': '1',
      'num': '1234',
      'dc_lat': '1',
      'tag_for_child_directed_treatment': '0',
      'tfua': '1',
      'npa': '1',
      'match_id':[your_match_id],
    }
  });
</script>
<noscript>
<img src="https://ad.doubleclick.net/ddm/activity/src=[floodlightConfigID];type=[activityGroupTagString];cat=[activityTagString];qty=1;cost=[Revenue];dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;tfua=;npa=;ord=[OrderID]?" width="1" height="1" alt=""/>
</noscript>
<!-- End of event snippet: Please do not remove -->

<noscript> section of event snippets

All event snippets contain a <noscript> section. This is used if a browser doesn’t support JavaScript and the main section of the Google tag can’t be used. In that case, an image tag will be used instead.

Make sure that you’re populating the parameters in the <noscript> section just like an image tag. The values in these parameters should match the values for the equivalent parameters in the <script> section of the tag.

Sample Google tag

Here’s an example of a complete Google tag, with both a global snippet and an event snippet:

Example Google tag

<!-- 
Start of global snippet: Please do not remove
Place this snippet between the <head> and </head> tags on every page of your site.
-->
<!-- Google tag (gtag.js) - DoubleClick -->
<script async src="https://www.googletagmanager.com/gtag/js?id=DC-[floodlightConfigID]"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'DC-[floodlightConfigID]');
</script>
<!-- End of global snippet: Please do not remove -->
<!--
Event snippet for Activity Name on http://www.foo.com: Please do not remove.
Place this snippet on pages with events you’re tracking.
Creation date: 10/30/2017
-->
<script>
  gtag('event', 'conversion', {
    'allow_custom_scripts': true,
    'u1': '[variable]',
    'send_to': 'DC-[floodlightConfigID]'/[activityGroupTagString]/[activityTagString]+[countingMethod]'
  });
</script>
<noscript>
<img src="https://ad.doubleclick.net/ddm/activity/src=[floodlighConfigID];type=[activityGroupTagString];cat=[activityTagString];dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?" width="1" height="1" alt=""/>
</noscript>
<!-- End of event snippet: Please do not remove -->

Adapt an existing Google tag for multiple Google products

If you already have a Google tag, you can configure it to send data to multiple Google products by:

  • Updating the global snippet to include identifiers for each product.
  • Using separate event snippets for each product.

Example adapted Google tag

Let’s use an example of a Google tag originally generated from a Google Analytics account. The global snippet would look like this:

<!-- Google Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments)};
  gtag('js', new Date());

  gtag('config', 'GA_TRACKING_ID');
</script>

To add support for your Display & Video 360 advertiser, you don’t need to add a second global snippet to your site. Just add the highlighted config command to your existing global snippet:

<!-- Google Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script><script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments)};
  gtag('js', new Date());

  gtag('config', 'GA_TRACKING_ID');
  gtag('config', 'DC-1234567');
</script>

 

For each additional Google product you want your tag to support, add a new config command with the right account identifier.

Note that the identifier in the src= part of the tag is set when you first generate a Google tag. It doesn’t determine which accounts will receive data from the tag. In the example above, the tag was originally generated from Analytics, so the src= contains an Analytics ID. Which accounts receive data from the Google tag is determined by the config command and by using event snippets specific to each product with a send_to field that routes to that product.

Frequently asked questions

Why is the Google tag placed in the <head> when iframe and image tags were placed in the <body> of my site?

Unlike iframe and image tags, the Google tag is an asynchronous tagging library. This means that a browser will download the tag without blocking the rendering of your page’s content, so you can place the tag at the top of your site between the <head> tags.

Where can I learn more about the Google tag?

You can learn more about using the Google tag across Google products:

Was this helpful?

How can we improve it?

Need more help?

Try these next steps:

Search
Clear search
Close search
Main menu
5117550313900941889
true
Search Help Center
true
true
true
true
true
69621
true
false