Google Ads dynamic remarketing with Google Tag Manager: a comprehensive step-by-step tutorial

What is Dynamic Remarketing?

Remarketing enables you to display ads to individuals who have visited your website or used your mobile app before. Dynamic remarketing takes this to the next level by showing previous visitors ads that showcase the products and services they viewed on your site.

By creating customized messages for your audience, dynamic remarketing can help you generate leads and sales by encouraging past visitors to return to your site or app and complete their purchase.

Do you need Google Ads consulting? Get in touch.

Why you should use dynamic remarketing

  • Scalable ads: By combining your inventory with dynamic ads, you can advertise all of your products or services easily.
  • Effortless feeds: Create a simple .csv, .tsv, .xls, or .xlsx feed. The Google Ads product recommendation engine will use your feed to choose the best combination of products for each ad based on popularity and what the visitor viewed on your site.
  • High-performance layouts: Google Ads selects the best dynamic ad layout for the person, placement, and platform where the ad will be displayed.
  • Real-time bid optimization: With enhanced CPC and conversion optimizer, Google Ads calculates the best bid for each impression.

Things you’ll need to begin with dynamic remarketing

To get started with dynamic remarketing, you’ll need:

  • A product or service feed that includes essential details about each item such as unique ID, price, image, and more. This information will be used to create dynamic ads tailored to your audience.
  • For website remarketing, add the dynamic remarketing tag with custom parameters to all pages of your website to associate your visitors with unique feed item IDs.
  • Create responsive display ads that automatically adjust their size and format to fit ad spaces. Find your dynamic remarketing tag in the Audiences section of your Shared library and learn how to tag your website for dynamic remarketing to get started.

Implement Google Ads dynamic remarketing with Google Tag Manager

Dynamic remarketing through Google Ads is a method of displaying tailored ads to individuals who have previously visited your website or used your mobile app. It goes beyond traditional remarketing by showcasing the specific product or service that the user had previously viewed on your site.

To set up dynamic remarketing with Google Tag Manager, you must:

  • deploy a Google Ads remarketing tag on every page of your website
  • pass dynamic values, such as product ID, origin and destination of a flight, or promotion ID, for each remarketing event to the remarketing tag at key stages of your website.

These dynamic values will depend on your website’s business objectives and can be captured using parameters defined for different business categories, such as education, jobs, or travel.

To ensure you are implementing dynamic remarketing correctly, it is recommended to review the dynamic remarketing guide on the Google Ads Help Center before attempting the tag implementation.

By doing so, you will gain a better understanding of the process and be able to select the appropriate event and parameter for your organization.

Dynamic remarketing can be implemented for any type of online business, and its success depends on the ability to capture and use relevant dynamic values effectively.

Steps for implementing dynamic remarketing

  1. Populate events and parameter values.
  2. Insert dynamic values into the remarketing tag.
  3. Specify triggers to activate the remarketing tag.
  4. Test the implementation and then deploy it.

Populate events and parameter values

To begin implementing dynamic remarketing, the initial step is to collect data from your website in a format that Tag Manager can process. You can capture data from your site by incorporating a Tag Manager variable. You can retrieve data from various sources like 1st party cookies, the data layer, or custom JavaScript.

Insert values in the remarketing tag

After configuring the remarketing tag to receive the target data as variables, the next step is to use those variables to input data into Tag Manager’s Google Ads remarketing tag template.

Specify triggers to fire the remarketing tag

The following step is to specify triggers that instruct Tag Manager when to activate each instance of the remarketing tag. You can establish triggers based on built-in variables such as pageviews, link clicks, button clicks, form submissions, and others.

Additionally, you can create triggers based on a custom event that registers in Tag Manager via the Data Layer.

Test and deploy

The final step is to test the remarketing tags on your website using Tag Manager’s Preview mode. Once you have completed all of the testing and verified that the tags are firing properly with the anticipated dynamic values, you may publish the container to deploy the tags.

To obtain comprehensive guidance on how to implement remarketing tags using Tag Manager, select the remarketing tag implementation method that you plan to use.

Implementation guide

The Implementation Guide below outlines how to implement Google Ads dynamic remarketing tags in Tag Manager using one instance of the remarketing tag for all stages of your purchase funnel.

The key stages for this process are:

  1. Configure your website to transmit values to Tag Manager using the data layer or custom JavaScript.
  2. Establish data layer variables in Tag Manager.
  3. Create triggers.
  4. Set up the remarketing tag with custom parameters.

Configure the data layer code on your site

To pass dynamic data to Tag Manager explicitly via the data layer, you need to set up the data layer code on your website. If you plan to obtain dynamic values through custom JavaScript variables in Tag Manager, you can skip this step.

To configure the data layer code, you should work with a developer. The dataLayer() object is used to pass custom data from your site to Tag Manager. This code should be placed above your container code so that the data is available when Tag Manager executes.

Below is a code snippet that shows how to create the data layer and pass the total cart value and list of products in the cart to Tag Manager:

dataLayer = []; dataLayer.push({ 'event': 'add_to_cart', 'value': 998.55, 'items': [{ 'id': 1234, 'google_business_vertical': 'retail'}, { 'id': 45678, 'google_business_vertical': 'retail'}] });

The key names used in the code snippet are arbitrary and don’t need to conform to any specific requirements. However, you must ensure that you use the same key name every time you pass the same type of information to Tag Manager.

To pass an items array, use JavaScript. The items object should have a key that corresponds to the primary identifier of the product or service (such as ID or destination) and a google_business_vertical key that represents the type of feed that the identifier should match against.

To verify that the data layer was correctly implemented and to view the data passed from the site to Tag Manager, Google Chrome users can use Tag Assistant.

It is important to capture dynamic cart events, especially when some funnel steps occur asynchronously, such as when a product is added to the cart without a full page reload. In such cases, you can use the dataLayer.push() method to update the data layer and fire tags after Tag Manager has loaded, as shown in the following example:

dataLayer.push({ 'event': 'add_to_cart', 'value': 78.45, 'items' : [{ 'id: '1234', 'google_business_vertical': 'retail' }] });

Set up variables

To implement dynamic remarketing tags with Tag Manager, it’s important to configure variables for each piece of dynamic data that needs to be passed to the remarketing tag. In this example, we’ll create three variables: ‘Event Name’, ‘Event Value’, and ‘Event Items’.

The ‘Event Name’ variable should describe the event being measured and is used by the Google Ads system to assign users to one of several automatically generated user lists. It’s recommended to use a specific set of event names from the list of recommended events described in the Google Ads Help Center.

The ‘Event Value’ variable should represent the total value of the products or services the user is interacting with.

The ‘Event Items’ variable should be an array of objects with properties following the dynamic remarketing item schema. Each item must have one or more of the following properties: ‘id’, ‘location_id’, ‘origin’, ‘destination’, ‘start_date’, ‘end_date’, ‘google_business_vertical’.

For more information on the list of events and parameters, refer to this Google Ads Help Center article.

Methods to get dynamic data through Tag Manager

There are different methods to obtain dynamic data through Tag Manager. One approach is to pass values explicitly to Tag Manager from your website via the data layer, or you can leverage custom JavaScript variables in Tag Manager to extract data from your site if possible.

Method 1: Update your website to pass values to Google Tag Manager through the data layer

This is the best method for configuring the remarketing tag. This approach involves making code changes on your website, but it will allow dynamic values to be passed directly to your remarketing tag.

I recommend using a specific set of event names from the list of recommended events. Once the event data is available in the data layer, you can create data layer variables in Tag Manager to pass these values to your tags. For instance, create a data layer variable for ‘items’ and another for ‘value’ by following these steps:

  1. Click Variables and then select New.Variables
  2. Choose Data Layer Variable.Data layer variable
  3. For Data Layer Variable Name, enter ‘items’.
  4. Click Save.

Follow the same steps as before to create a second Data Layer Variable in Tag Manager, but this time use ‘value’ for the Data Layer Variable Name. This will allow Tag Manager to extract the ‘value’ information from the data layer and pass it on to your remarketing tag.

Developers can find additional information on data layer implementations at the Tag Manager developer site.

Method 2: Use custom JavaScript variables

An alternative method to capture dynamic data is to use custom JavaScript variables. This approach can be practical when deploying remarketing tags as it doesn’t require any code changes on your site.

Custom JavaScript code can be written to extract the dynamic parameter values from the existing page source code and pass them to the tag.

However, this method is less robust than using the data layer and relies on the site’s source code at the time of implementation. Any future changes to Tag Manager may require revising the custom JavaScript code.

More information about data layer implementations can be found on the Tag Manager developer site.

If you have implemented the data layer on your website

Assuming you have set up the data layer on your website, select “Data Layer Variable” as the type of variable and provide the name of the data layer key where Tag Manager can retrieve the relevant data for the variable you want to set up.

If you haven’t implemented the data layer on your website

If you have not implemented the data layer, you can still extract the dynamic value needed from the source code using a Tag Manager JavaScript Variable. First, identify the variable from your existing JavaScript code, and create a JavaScript variable in Tag Manager that uses the same name as the variable.

Keep in mind

If you rely on custom JavaScript variables to capture dynamic parameter values and do not use the data layer, you may need to use different strategies to populate the same custom parameter depending on the funnel step.

For example, the way you capture the product ID on a product page may differ from the way you capture it on the cart or purchase confirmation page, as the source code or JavaScript variables you can use will vary for each step.

Hence, you may not be able to create a single product ID variable that works for every scenario. Instead, you will need to create one variable for each scenario where you require this information.

Set up triggers

Pageview-based triggers

When creating triggers, they are typically based on a specific page view or a group of pages. For example, an ecommerce site may require triggers for all product pages, the cart page, and the purchase confirmation page.

To create a pageview-based trigger:

  1. Navigate to Triggers and click New.Triggers
  2. Select Trigger Configuration and then Page View.
  3. Configure the trigger to fire on Some Page Views.Some page views
  4. Under the “Fire this trigger when an Event occurs and all of these conditions are true” section, input “Page URL” followed by “contains” and then <path>, where <path> represents a predictable part of the URL for the pages where you want the tag to fire, such as “/products/”.
  5. For triggering on a group of pages, such as product pages, use operators such as “contains” or “matches regular expression” to match the desired page URLs.

Non-URL triggers

In some cases, the URL may not be sufficient to distinguish between different types of pages. In such scenarios, you may be able to use other variables to filter the pageview event. For instance, an ID attribute may be present in the HTML code.

To create a trigger that fires when this attribute is found:

  1. Click Triggers and then New.
  2. Click Trigger Configuration and select Element Visibility.Element visibility
  3. Set Selection Method to ID.
  4. In the Element ID field, enter the ID attribute value you want to target (e.g., cart_title).
  5. Set this trigger to fire only once per page.
  6. Set Minimum Percent Visible to 1%.
  7. Set the trigger to fire on All Visibility EventsTrigger configuration

Asynchronous events

To optimize your dynamic remarketing campaigns, it’s crucial to fire tags as soon as a user completes a significant step in the buying funnel, such as adding a product to their cart. If the cart update doesn’t lead to a new page view, you can use a click event or a custom event to trigger the tag.

If you’ve implemented the data layer, use a custom event to inform Tag Manager that a product has been added to the cart and pass the relevant product information simultaneously. Your website code should use dataLayer.push() to add an event to the data layer when an item is added to the cart:

dataLayer.push({
‘event’: ‘add_to_cart’,
‘value’: 78.45,
‘items’ : [{
‘id’: ‘1234’,
‘google_business_vertical’: ‘retail’
}]
});


Once you have added the event to the data layer, create the trigger in Tag Manager:

  1. Click Triggers and then New.
  2. Click Trigger Configuration and select Other: Custom Event.
  3. Set the Event Name to add_to_cart.

Tip

If you haven’t implemented the data layer, set up a click-based trigger to fire a tag when the user clicks a button.

Set up tag instance

To set up the remarketing tag, follow these steps:

  1. Click on Tags and then New.
  2. Select Google Ads Remarketing from the Tag Configuration options.
  3. Set the Conversion ID (and optional Conversion Label) provided by Google Ads. To find the Conversion ID, see this page.
  4. Use a Constant String variable for your Google Ads Conversion ID to make it easier to create and manage additional Google Ads tags. In GTM, a constant variable is a valuable tool for storing static or dynamic values that you need to use regularly or may need to update in the future. With constant variables, you can store and reuse these values throughout your container, making it easier to maintain and update your tag configurations.
  5. Check the box labeled “Send dynamic remarketing event data” and reference the Tag Manager variables that you created earlier:
  • Event Name: {{Event}}
  • Event Value: {{value}}
  • Event Items: {{items}}

By following these steps, you can configure the variables to receive dynamic data, set up triggers to fire the remarketing tags, and finally configure the remarketing tag instance to send dynamic event data.

Implement a conversion tag

To take advantage of real-time automated bidding algorithms like Target CPA and Target ROAS, it’s recommended to implement the Google Ads Conversion tag along with the remarketing tag.

To do this, create a new Google Ads remarketing tag, set the firing trigger to all pages, and add all the triggers that were created for the other tags as blocking triggers:

  1. Click Tags and then New.
  2. Click Tag Configuration and select Google Ads Conversion Tracking.
  3. Set the Conversion ID (and optional Conversion Label) to the value provided by Google Ads.
  4. Click Triggering and select a trigger that will fire on all pages.
  5. Click Add Exception and enter an exception for each trigger already covered by the custom parameters entered above.

Test and deploy

Before deploying your Tag Manager configuration, it is essential to thoroughly test it to ensure it functions as expected.

Testing with different scenarios such as adding various products to the cart, viewing the cart with multiple products, and completing a purchase is recommended.

Keep in mind

It’s also best practice to write custom JavaScript code within a try/catch block to prevent errors from raising exceptions. When testing your code, remove the try/catch block so you can observe any errors that appear in the console.

Once you’ve verified that your code works correctly, add the try/catch block back again.

Finally, after testing, publish your container to activate your Google Ads dynamic remarketing configuration.