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

589
Visualizações
Error in GTM: This language feature is only supported for ECMASCRIPT_2015 mode or better: const declaration

I am trying to parse UTMs and get them into fields but it seems that my script won't publish on GTM.

(the script works when directly put on webflow custom code)

  var queryString = window.location.search;
  console.log(queryString);
  // ?utm_source=facebook&utm_medium=post&utm_campaign=webflow
  var URLSearchParams_wb = new URLSearchParams(queryString);

  const utmParameters = [
    "utm_campaign", 
    "utm_source", 
    "utm_medium",
    "utm_content",
    "utm_term"
  ];

  for (const utm_element of utmParameters) {
    /* if utm_source exist */
    if(URLSearchParams_wb.has(utm_element)){
      console.log(utm_element + " : is exist");
      /* get UTM value of this utm param */
      var value = URLSearchParams_wb.get(utm_element)
      /* change form hidden feild to this utm url value */
      $("."+utm_element).val(value);
    }
  }/* end for loop */
</script>```

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

0

Yes, GTM has troubles adopting ES6. Therefore:

  1. Get rid of consts. Use vars instead.
  2. That jquery piece. better get rid of it too. You don't need a dependency on jquery living in GTM. But it doesn't break the code.
  3. Your for of construction is from es6 too, I believe: https://kangax.github.io/compat-table/es6/ so the loop will likely have to be rewritten to something different. I would just use forEach rather than that for of.

The rest should be good. Give it a shot.

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