Shopify Google Dynamic Remarketing Tag with Custom Parameters

The quick and easy approach to setting up custom Google Remarketing parameters in Shopify is to use the following tags (typically in your theme.liquid).

{{ }}
{{ template }}
{{ product.price_min | money_without_currency }}

The issue that you’ll run into though, is that Google complains when the ecomm_totalvalue is wrapped in quotes.

So, we just remove the quotes, right?

Not exactly.  Not every page on your site will be a product page, and hence will not have a price.

On the home page, for example, that would leave us with an invalid object:

ecomm_prodid: ‘ ‘,
ecomm_pagetype: ”,
ecomm_totalvalue: ,

One pretty quick trick that I use is to simply add a zero (0) before the value, as shown below.

<script type="text/javascript">
 var google_tag_params = {
 ecomm_prodid: '{{ }}',
 ecomm_pagetype: '{{ template }}',
 ecomm_totalvalue: 0{{ product.price_min | money_without_currency }},

Using this method, the worst that happens is you might get a price that looks like this:


Which is still a valid numeric value.

Why follow me on Twitter?

  • I tweet about new technologies, services or libraries I find interesting
  • Yeah, sometimes I'll post a pet-peeve or rant about something trivial
  • If I discover something that made my web development life easier, I share it
  • I'll shout out any handy tip that I think might be useful to other devs

Tagged , .

Updated: 2018-04-14

Phil LaNasa follow us in feedly