Dynamic Remarketing with Google Tag Manager


Remarketing is a common method of digital advertising that many companies use to show ads to people that have visited their website in the past. For a more personalized message, dynamic remarketing can be used to tailor ads to users that feature specific products they viewed. This can be useful for encouraging users to complete a purchase when they left an item in their shopping cart, for example.

While there are a few different methods for implementing dynamic remarketing, this post aims to serve as a best-practice how-to guide to get you up and running with one of the basic methods of implementing dynamic remarketing with Google Tag Manager and AdWords. The particular industry that we will review here will be the Retail industry, although there are a variety of industries that Google supports with pre-defined attributes.

The general process will look like this:

  1. Get the information we need
  2. Put the information into the data layer
  3. Configure a remarketing campaign in AdWords
  4. Configure GTM to collect the dynamic information for use in the remarketing campaign

You will need to have Advertising Features enabled in your Google Analytics account and have your Analytics and AdWords accounts linked in order to use Dynamic Remarketing. Retail Dynamic Remarketing, which we will be talking about here, also requires that you link your Google Merchant Center and AdWords accounts as well.

Let’s get started!

1. Get the Information We Need

The first step in setting up Dynamic Remarketing is to find the relevant information that you want to use for your remarketing strategy. This will vary based on your business type and goals, and may be product- or service-related. For this post, we will be talking primarily about the retail industry, so this information will be product-related.

For example, we are going to use a product ID, page type, and product value. Ecommerce tracking also requires some of these values, which means that if we have ecommerce configured already we should be able to repurpose a lot of that data for remarketing; and we do not need to go back to our developers and ask that they make yet another update to the page.

To find out exactly which pieces of information you will need (and which ones you are required to have in order for this to work), take a look at the Google Developers Remarketing resource article, which provides a list of industry-specific parameters such as for education, travel and more.

So what do those parameters mean? Each parameter’s purpose is defined in the Help article mentioned above, but let’s take a closer look at the retail parameters:

  • ecomm_prodid: This is the ID of the product viewed on a given page. This parameter is required whenever the ecomm_pagetype is set to product or cart. More than one product ID can be passed on cart pages.
  • ecomm_pagetype: This designates the type of page that was viewed. Possible values include home, searchresults, category, product, cart, purchase or other. You will need to map the pages on your site to fit into one of these categories.
  • ecomm_totalvalue: This is the value of the product viewed, which may change depending on whether the product is being viewed from a product detail page or in a cart.
  • ecomm_category: This is the category to which the product or category page being viewed belongs.

Additional information can be passed along within custom parameters as well, such as productname, productsale, etc.

An important takeaway here is that certain parameters are required for each website type, such as ecomm_prodid for retail websites. Refer to the documentation to make sure that you include the required parameter(s) for your industry.

2. Put the Information in the Data Layer

In a manner similar to that of ecommerce tracking, a script needs to be placed on applicable pages that dynamically populates the data we just described in order for us to grab it with GTM and use it for our remarketing purposes. The script should be placed on key pages of your website, such as on checkout steps, for example. It is most efficient to dynamically populate all of the variables you need. If you cannot dynamically populate the pagetype-specific variable, you can create separate tags for each page type.

Another, less preferred option is to use a DOM element variable to pull information off the page. If you use this method, make sure to set your remarketing tag to fire on gtm.dom instead of on the pageview. More details on these and other options can be found from the documentation pointed out above, although the steps explained in that documentation almost make the process more confusing – so we’re going to use a dynamic pagetype parameter.

Configure dataLayer.push declaration that defines the variables you need. This data layer should be placed above the GTM container and would look something like this:

Followed by your standard GTM container:

3. Configure a Remarketing Campaign in AdWords

In your AdWords account, create a remarketing campaign in your AdWords account and generate the remarketing tag in the Audiences section of your AdWords Shared Library. Be sure to check the “use dynamic ads” checkbox and then select your industry.

create a remarketing audience

Once you create your new remarketing tag, remember your Conversion ID and Conversion Label for our next and final step.

4. Configure GTM to Collect the Dynamic Information for Use in the Remarketing Campaign

Now that the on-page code is configured and you have your Conversion ID and Label, we can finish the implementation within GTM.

Create new Data Layer Variables for the data you want to pull out of the data layer. For example, ours will look like this:

remarketing data layer variable

remarketing data layer variable

remarketing data layer variable

Then create a new AdWords Remarketing tag – insert into the tag your Conversion ID and Conversion Label:

remarketing tag in GTM

Under the Custom Parameters options, we selected “Manually Specify” since we are repurposing information that is already available to us in the data layer from our ecommerce configuration – this is where we add the key-value pairs for each of our data layer variables. Repurposing data layer variables helps reduce the number of requests we need to make to IT teams. It is important to note that the keys need to be in the specific remarketing format you see above.

You also have the option to select “Use Data Layer” which would automatically grab the parameters for you – but you would instead set up your data layer so that each of your remarketing parameters are inside a single object, such as in this example:

In this case, you would need a Data Layer Variable called google_tag_params to insert into the remarketing tag so that GTM knows where to find the parameters it needs:

remarketing tag in GTM

Since we are populating the ecomm_pagetype parameter dynamically and before the GTM snippet, we can use a Pageview trigger to fire the tag.

Test and publish your new tags, and you’re all set!

There are a few different ways you could go about configuring dynamic remarketing with Google Tag Manager. The process described here aims to be as straightforward as possible, reusing information that is already available to us for our retail remarketing example. If you have used other methods or have some useful tips from your own experience, please share in the comments.

Amanda Schroeder is a Senior Consultant and comes from the marketing industry where she found a need for accurate, insightful data that could aid in making results-driven decisions. Amanda’s passion for building solid measurement strategies and connecting all the pieces of integrated digital and traditional marketing campaigns has led her to her current role at LunaMetrics.

  • akkkkkar

    Very useful, thank you. Made our retargeting campaign run in 48 hours. Perhaps you also should say something more about how to configure the campaign in Google AdWords.

  • Rahul

    Hi, thanks for post. What will be the logic if someone does not want to fire this on cart page. I read on support page of google that this should not fire on cart page?

    • Amanda

      Hi Rahul,

      If you take a look at the documentation for retail sites (link below), you can see that the required ecomm_pagetype can be either “product” or “cart” – which indicates the type of page that the tag is on. If you do not want a particular tag to fire on a specific page, you can use a blocking trigger.

      Here is the link to the documentation:


      Hope that helps clarify things!

  • Wrig Mark

    Great Post!! Nicely done the key part of dynamic remarketing.

  • Andrey

    Hi, thanks for post.
    Is it possible to do like this:

    dataLayer = [];

    ‘job_pagetype’: ‘offerdetail’,
    ‘job_id’: ‘123’,
    ‘job_locid’ : ‘UA-7’

    declare details below GTM?

    • Amanda

      Hi Andrey,

      If you want to declare the data layer ecommerce information after the GTM container, you will need to add a GTM event and change the trigger for your remarketing tag so that it fires only when the ecommerce information it is available (when the GTM event is pushed into the data layer).

      For example:

      ‘job_pagetype’: ‘offerdetail’,
      ‘job_id’: ‘123’,

  • Terral

    Hello Amanda,

    Thanks for the great article! I’ve had a hard time recently finding detailed information on Google Tag Manager, and LunaMetrics has been a god sent!

    I have a few quick question regarding the DataLayer:
    1) For a dynamic remarketing tag to work, do I have to have a custom DataLayer push for each product I have listed on my website?
    2) Is there a way to dynamically populated the ProdID, Pagetype, Category and Total Value?
    3) Finally, do I need to insert the code for the datalyer push on every product page or can I simply insert one code on my checkout page that automatically populates with the correct parameters?


    • Amanda

      Hello Terral,

      I’m glad you’re finding our posts helpful. To answer your questions –

      1.) No, you do not necessarily need the code for every product you have on your website. Depending on what your overall goal is, you may want to use remarketing for all of your products, or just particular products in a certain category, for example.

      2.) You can dynamically populate the data layer values by programmatically adding them via your server-side code. You may need to talk with your IT staff or whoever set up your website in order to make this work. The information is already there on your server, it’s just a matter of surfacing it in a way that GTM can use it.

      3.) If you want to only remarket to users who have seen a checkout step page, you can do that. You do not need to remarket to users who have only seen a product page. Just remember to specify the ‘ecomm_pagetype’ value of ‘cart.’



  • AJ Saunders

    Thanks for providing a common sense – step by step guide. I’ve being trying to get this to work for about 8/9 months and you provided a solution that google couldn’t!

    • Amanda

      Glad to hear this was helpful to you AJ!

  • Arun kumar Jha

    Hello Amanda,

    Below are the data layer script i set up for dynamic re-marketing. Please check and let me know it will work or not. I will set up remarketing tag by using tag manager.

    var dataLayer = window.dataLayer || [];


    ‘google_tag_params’: {

    ‘event’ : ‘dynamic_rm’,

    ‘edu_pid’ : ‘Value’,

    ‘edu_pagetype’ : ‘Value’,

    ‘edu_url’ : ‘Value’,

    ‘edu_course’ : ‘value’,

    ‘edu_technology’ : ‘value’



    • Amanda

      Hello Arun,

      Sorry for the late response. This format looks appropriate to me, as long as you’re using the appropriate values for the predefined parameters (such as ‘home’ or ‘searchresults’ for the ‘edu_pageType’ param).

  • Singh Birendra


    I have question over your statement -“You will need to have Advertising Features enabled in your Google Analytics account and have your Analytics and AdWords accounts linked in order to use Dynamic Remarketing.”

    If we are collecting remarketing data via GTM, then why we need Advertising Features enabled in Google Analytics and what is the need of Analytics and AdWords accounts linking?

    As I know, if we are running dynamic remarketing via Google Analytics code then both above said are required.

    Can you please give more details on your statement.

    Birendra Singh

    • Amanda

      Hi Birendra,

      If you want to see Demographics and Interests reports, for example, you will need to enable Remarketing and Advertising Reporting Features in Google Analytics.

      Additionally, if you want to use the dynamic remarketing audiences of Google Analytics in Google AdWords, you will need to have Google Analytics and Google AdWords linked.


  • Lewis Fantom

    Hello Amander,

    I had a quick question.

    Can you add or list multple product categories if a product was to have multiple?

    I know for example with Enhanced Ecommerce you can list categories but have to seperate them with a /



    Here i would want to pull both to refine targeting.

    • Amanda

      Hello Lewis,

      That is a good question. It looks to me as though you can send multiple values for any parameter as long as they are in an array (according to the documentation on this page under “formatting custom parameters and identifying common errors” – https://support.google.com/adwords/answer/3103357).

  • Klaus

    I love you Lunar Metrics 🙂

  • Patrícia

    Hello, Amanda.

    When we go to the remarketing script it says, for example, dynx_itemid: ‘REPLACE_WITH_VALUE’,
    In this case, how can I replace with value? I’ll do how you said, but how all the info goes to the parameter? Is it automatically?


    • Amanda

      Hi Patricia, you’ll have to programmatically add the value that you want in there so that whenever a given page loads, you will see an item ID instead of ‘REPLACE_WITH_VALUE’. You may need developer assistance.

  • Hello Amanda! I will know about the Google Tag manager but I did not know before the dynamic remarketing. Amanda thanks again for sharing.

  • Darko Videnov

    One question. If I set up the remarketing tag as explained in the article, and for example I have two products in my cart and they are in my dataLayer. GTM remarketing tag is suppose to get both product_ids and place them in the ecomm_prodid variable by default or do I have to write a for () to place them?

    • Amanda

      Hi Darko,

      If you are using the enhanced ecommerce structure for your dataLayer values, then yes – you should create a variable in GTM that goes through the dataLayer and pulls out all of the ID’s.

  • Josh

    Hi Amanda, very helpful, what if i wanted to filter certain products so that only high value products we’re in the dynamic remarketing product ad shown to users. Is there an arbitrary variable (i believe grouping is the label in the shopping dynamic variable settings) that you can use to segment by highvalue item. What would that variable look like?

    • Josh

      This is for a retail client

Contact Us.

Follow Us




We'll get back to you
in ONE business day.
Our Locations
THE FOUNDRY [map] LunaMetrics

24 S. 18th Street
Suite 100

Pittsburgh, PA 15203


4115 N. Ravenswood
Suite 101
Chicago, IL 60613


2100 Manchester Rd.
Building C, Suite 1750
Wheaton, IL 60187