Google Ads Certified

Microsoft Ads Certified

Facebook Ads Certified

Dynamic Remarketing Without Data Layers!

On average, it takes approximately five to seven touchpoints to close a sale. So in order to have a proper digital marketing strategy it is crucial to have a remarketing campaign. The best of all remarketing campaigns is dynamic display remarketing. This is because it shows the exact product that the user viewed but did not purchase! When setting up a dynamic remarketing campaign on Google Ads it’s highly recommended that you utilize data layers via Google Tag Manager. However, if you work with a web development agency or don’t have access to your source code this isn’t possible to do. There is another way to accomplish this through custom JavaScript variables.



  • Needed Dynamic Remarketing On Website
  • Low Budget
  • 3rd Party Web Development Agency

In this specific case I needed to implement dynamic remarketing to product description page visitors. This is because I was running multiple Google Shopping campaigns that used these as the landing page. I wanted to target users who didn’t convert to see the exact products they viewed as they browsed sites and apps in the Google Display Network. The problem was that the web development agency would charge too much money for the current budget.


  • Created Dynamic Remarketing – Google Ads Tag
    • Custom JavaScript Variables
    • Triggers On Each Product Description Page
  • Troubleshoot via Google Analytics, Google Ads & Google Merchant Center


Determine DOM Elements To Track

When setting up dynamic remarketing it is crucial to have the proper variables to be grabbed from the DOM such as product id, page type & price. This is so that the data can be pushed to Merchant Center. Once Merchant Center grabs this information it can choose the correct item id and attributes to shown in your dynamic advertisements.

Why These Elements?

In order to find the unique values in each product description page (which was the landing page) I utilized Chrome Developer Tools. I would inspect the item id element & price element. From here I would check the css selector of each element. This would allow me to dynamically fetch this data with a custom JavaScript function via Google Tag Manager.

CSS Selector

Google Tag Manager

Creating The Custom JavaScript Function

The function that I created is quite simple. It takes the inner most level of the css selector string data. Next, it takes the data and cleans it to have the pure string integer.

Product SKU Function

This replaces a data layer variable which would have the information nice and neatly pushed through the layer. Another function that I needed was to keep all of the products visited during the user’s session. This was primarly to make sure that the configuration was not off when setting up the Google Remarketing tag.

Function To Capture All Product IDs

What’s So Bad About A Custom JavaScript Implementation?

When basing your tracking off of fragile DOM elements instead of data layers, any small change in the web page can break your tracking. So I have to consistently check to make sure there are no major html changes to the website or it could affect the campaign.

Triggers & Tags Oh My!

Now that I had the custom JavaScript variable fetching all the product id’s & prices it’s time to set triggers for these events. This portion maybe be a little more difficult depending on how the website was structured. The idea is that tags will be triggered on DOM elements that are only on product description pages. Also, to be extra careful I set anti-triggers on unique elements on home, cart and category pages. I set this to fire when the DOM is ready not at a page view this may be too soon in some circumstances.

Putting It All Together

Now that I had the variable and trigger set up I created the tag that holds it all! First, I choose the Google Ads Remarketing (pre-built into GTM) and filled out the empty fields. Make event name something you can easily remember such as dynamic-product-remarket. For event value choose the variable name that I created to grab the product price on description pages. For event items I used the function that holds all product ids in the session.

Custom Parameters

In this section of the tag configuration I needed to utilize the custom parameters that I created in Google Analytics in the admin settings. These are predefined custom dimensions in Google Ads documentation that you can utilize to capture product ids, page types and total value of each page. The keys with be product id & google_business_vertical in my case was retail.

Trouble Shooting Configuration

Google Tag Manager Preview Mode

Now that I had gone through this process I had to trouble shoot to make sure that all the analytics tracking was grabbing the correct audience. This took a few days to properly configure because of the lag between Google Products(Ads, Analytics, Tag Manager). Also, the actual lag between getting real traffic to the website. The audience that I wanted to appear was the prebuilt Product Viewers(Retail)(Google Ads). This audience naturally grew the more I advertised.


Through this challenge it taught me a creative way to solve my problems without the help of a developer. I believe this is a very critical skill in all areas of business not only marketing! I will continue to hone my JavaScript skills to leverage didn’t analytics tracking, ads management and search engine optimization!

Leave a Reply