Google Ads API is returning to beta status. Please read our blog post for more details.

Prerequisites

Install Global Site Tag and Remarketing Event Snippet

To implement dynamic remarketing, you need to tag your site for remarketing. You can retrieve the googleGlobalSiteTag or event_snippet via the API from the TagSnippet of the conversion_action field.

Here are the steps for embedding tags in your website manually:

  1. Get the global site tag and the remarketing event snippet.

    The global site tag sets a new cookie on your site which collects information about the ad click that brought a visitor to your site and adds website visitors to standard remarketing lists in your Google Ads account.

    To make sure the tagging works with dynamic remarketing, select Collect specific attributes or parameters to personalize ads during the step Create the Google Ads tag data source, as shown below:

    Detailed instructions for acquiring the global site tag and remarketing event snippet can be found on this help page.

  2. Install the global site tag.

    You must install the global site tag on all the pages of your website that send remarketing information, but you need only one global site tag for each Google Ads account. The event snippet can be used to track additional actions that are to be counted as remarketing events. Install this snippet on site pages you'd like to track, right after the global site tag in the <head></head> section.

    The global site tag also works with other tags such as Google Analytics tags. Read more about how tags work in Google Analytics.

  3. Install an event snippet on site pages you would like to track, with corresponding custom parameter values.

    Custom parameters are elements in your remarketing tag code that allow your tag to send information about specific items or selections on your website to your Google Ads account. Custom parameters are directly related to business data feeds, where you add the values that correspond to the information the tag collects.

    To use dynamic remarketing, you'll need to use the custom parameters marked as Required on this page.

    When you add the value of a custom parameter to your remarketing tag, it will sync with your feed to show the same product or service in your ads previously viewed by the same visitor.

    Here is an example of how to install an event snippet for a retail site (note the ecomm_prodid is the Merchant Center Product ID that corresponds to the product on the page):

    gtag('event', 'page_view', {
      ecomm_pagetype: 'product',
      ecomm_prodid: 34592212,
      ecomm_totalvalue: 29.99,
      ecomm_category: 'Home & Garden',
      isSaleItem: false
    });
    

    In addition to the standard business types, dynamic remarketing parameters also support the use of custom feed templates via the dynx_itemid, which provides more control over feed contents. Note that dynx_itemid corresponds to the ID of the FeedItem of an item on the page). Here is an example:

    gtag('event', 'page_view', {
      dynx_itemid: ['CORS9', 'XSS7'],
      dynx_pagetype: 'conversionintent',
      dynx_totalvalue: 78.98
    });
    

    For detailed definitions of the parameters and their valid values, refer to this guide.

    The event name you use (e.g., page_view in the above example) can be a custom event name of your choosing or one of our recommended standard events. It doesn't need to match any specific value for the purpose of implementing dynamic remarketing, as long as the event data parameters (ecomm_pagetype, ecomm_prodid, and ecomm_totalvalue in this example) are correctly set.

    For detailed documentation on custom parameters for different business types and how gtag.js works, refer to Dynamic Remarketing Parameters and gtag.js for Remarketing.