No event is tracked in Google Analytics when the user is logged out

Viewed 26

No event is tracked in Google Analytics events when user is logged out, but it works when a user is logged in.

I've deployed this part of code on my stagging environment, I can see the expected result in Google analytics, but only when the user is logged in. Based on my logs, I can also see that the gtag function is called every time, but still, no event is logged when I'm logged out.

The index.html has the following script attached:

<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());

GTag configuration:

gtag('config', 'G-number',
      {}
);

and my button component has the gtag call:

sendGTag(url, userProfileId) {
  gtag('event', 'resource', {
    'userId': userProfileId,
    'curentPage': this.baseUrl,
    'resourceFile': url,
    'datetime': new Date()
});}
0 Answers
Related