Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
How to use Shopify liquid variables in Google tag managers tag

I am fairly new to GTM. I need to put this script to our Shopify product pages. It is for an email marketing automation saas.

If I put it directly into the code of the page in Shopify, it renders well and comes back with a product id that is fished from the liquid code above. It looks like this:

<script type="text/javascript">
Targito.push( 'event', 'product_view', { 'id' : '{{ product.selected_or_first_available_variant.id }}' } );
</script>

But when I want to put it into Google Tag Manager, as custom HTML tag, and then add the variable into variables in GTM, after I publish it, on the page, in inspect tool and elements, it comes back as this:

<script type="text/javascript" id="">Targito.push("event","product_view",{id:"{{undefined}}"});</script>

I need to see a product id of the page you are currently viewing.

The thing is, Shopify liquid variables are also defined with double curly brackets, so are GTM variables. Would anyone be able to help me please? Highly appreciate your tips in advance.

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You can't put liquid code inside your tag. The tag is rendered in Javascript that is on client side. Liquid is rendered on server side. You will need to populate a variable with liquid and use that in your tag. There are other ways but the fastest is doing something this.

You put this in your .liquid template (somewhere at the beginning of the page)

<script>
window.myVariantId = '{{ product.selected_or_first_available_variant.id }}';
</script>

And then in your tag you can put

<script type="text/javascript">
Targito.push( 'event', 'product_view', { 'id' : myVariantId } );
</script>
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda