Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

456
Visualizações
Google Tag Manager Variable Parse Error: Primary Expression Expected

I am setting up a GTM variable, and I thought this error only came up when you don't wrap all of the code in a function.

Here is my code:

    function VIN() {
      let vins = document.getElementsByClassName("xyzClass").innerText;
      let targetVIN;
      for (var i = 0; i < vins.length; i++) {
        if (vins[i].innerText === "VIN") {
          targetVIN = vins[i].nextSibling.innerText;
        }
      }
    return targetVIN;
    });

GTM is throwing the error in the title in reference to line 2 character 2.

I'm a noob, what am I doing wrong here? Thank you in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This will not work in a variable, since a custom JS variable requires an anonymous function, and yours is a named function.

It will also not work in a custom HTML tag, because GTM does not support ES6 features in custom tags and in variables (although it is partially supported in custom template, but those to do support DOM access).

If you use this in a custom tag, just replace "let" with "var".

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda