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

136
Visualizações
How to send EVENTS in addition to pageviews using a Java Script GTM tag which is tracking Individual Logged in Users using Google Analytics?

I have used a JavaScript tag which is tracking Individual Logged in Users using Google Analytics. It has a statement "ga('send', 'pageview');", which results in showing the pages a particular user has viewed, in user explorer of Google Analytics. I want to send events (I have already created in GTM) along with pageviews with reference to User-ID i.e., shKey in my case.

Here is the code in my JS tag;

 <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
    ga('create', 'UA-xxxxxxxxx-x' , 'auto');
    ga('set', 'userId', arguments.shKey);
    ga('set', 'dimension1', arguments.fname);
    ga('set', 'dimension2', arguments.type);
    ga('send', 'pageview'); 
    ga('send', 'event');
    </script>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

  1. Your ga('send', 'event') has a wrong signature. Events require category and action. So your event should look something like: ga('send', 'event', 'category', 'action', 'label');
  2. You're doing it strategically wrong. You're solving through JS what is supposed to be solved via GTM UI. In short term, it may seem easier and more elegant to do it in JS. In long term, however, it makes GTM obsolete and increases your technical debt, so the implementation becomes really difficult to maintain.
about 4 years ago · Juan Pablo Isaza Relatório

0

You have 2 issues: your code won't send an event (you're missing parameters), and you need to address PII (see further below)

This is how you send an event programmatically:
https://developers.google.com/analytics/devguides/collection/analyticsjs/events

ga('send', 'event', 'My Category', 'My Action', 'My Label');

However if you're using GTM, you might want to look into how to handle events with GTM:
https://developers.google.com/tag-manager/devguide

// You need to configure GTM UI to handle below event as desired
dataLayer.push({'event': 'event_name'});

Regarding PII, this is the authoritative answer from Google:
https://support.google.com/analytics/answer/6366371?hl=en

Google policies mandate that no data be passed to Google that Google could use or recognize as personally identifiable information (PII). PII includes, but is not limited to, information such as email addresses, personal mobile numbers, and social security numbers

If you want to use PII, it must be encrypted before being sent, from same link as above:

You can send Google Analytics an encrypted identifier or custom dimension that is based on PII, as long as you use the proper encryption level. Google has a minimum hashing requirement of SHA256

On top of that there might be additional legal restrictions depending on the jurisdiction you and your customers are in (eg in Europe you would have GDPR).

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