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

347
Visualizações
GTM Event: How do I get the label text for checkbox clicked

I have a form which I want to use Google tag manager to get the label text as an event label when someone clicks on the checkbox. I was able to get it to work when a user clicks on the actual label, but doesn't work when the user click on the checkbox rather than the label.

What I am trying to do is to get the text located by the side of the check box. from the example HTML code of the checkbox (pasted below), you can see both the checkbox and text are inside the tag and I need to get the text located next to the checkbox.

code

<div class="stockist-search-filter-checkboxes">
<div class="stockist-search-filter-checkbox">
<label>
<input name="filters" type="checkbox" value="11222">Home Specialist
</label>
</div>
</div>

code

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

0

Well, you can change a selector to catch the checkbox click rather than the label click. Or you can add an event listener to the checkbox on page load and send a dataLayer event from it for GTM to fire your event.

If this is not enough for you to resolve it, show your html around the checkbox (NOT as a screenshot) and show how you configured the trigger (as a screenshot).

Here's a code sample for adding a listener that pushes the DL event on checkbox changes.

var checkbox = document.querySelector("input[name=checkbox]");

checkbox.addEventListener('change', function() {
  dataLayer = dataLayer || [];
  dataLayer.push({
    event:"checkbox_changed",
    checkboxIsChecked: checkbox.checked,
    checkboxName: checkbox.getAttribute("name")
  })
});

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