Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ga-lite doesn't track when Google Analytics does ('Do not track' difference) #53

Closed
Jos512 opened this issue Jan 12, 2018 · 2 comments
Closed

Comments

@Jos512
Copy link

Jos512 commented Jan 12, 2018

Earlier this week I added ga-lite to my website and it worked. Or perhaps it seemed to work, because today it doesn't create a call to www.google-analytics.com. If I replace ga-lite with the Google Analytics JavaScript code, there is a call to www.google-analytics.com.

Ga-lite code

Code I tried:

<script>
window.galite=window.galite||function(){(galite.q=galite.q||[]).push(arguments)};
galite('create', 'UA-12345678-1');
galite('set', 'anonymizeIp', true);
galite('send', 'pageview');
</script>

// ...

<script async defer src="https://cdn.jsdelivr.net/npm/ga-lite@2.0.1/dist/ga-lite.min.js"></script>

And:

<script>
(function(e,t,n,i,s,a,c){e[n]=e[n]||function(){(e[n].q=e[n].q||[]).push(arguments)}
;a=t.createElement(i);c=t.getElementsByTagName(i)[0];a.async=true;a.src=s
;c.parentNode.insertBefore(a,c)
})(window,document,"galite","script","https://cdn.jsdelivr.net/npm/ga-lite@2/dist/ga-lite.min.js");

galite('create', 'UA-12345678-1', 'auto');
galite('send', 'pageview');
</script>

I do see that the script from cdn.jsdelivr.net loads in both Firefox and Chrome. But there isn't a resulting call to www.google-analytics.com to actually send the data to Google Analytics. (I of course verified that I don't have a browser setting that blocks requests to that address.)

I neither see an error message appearing in the 'Console' of the webdeveloper tools of Firefox and Chrome. (I tried both browsers.)


This issue does not only happen on my localhost test website. Here is a speedtest of Jehna's website that shows a HTTP connection error for the request to www.google-analytics.com. This is another speedtest for the same page, but this time from Melbourne. Here the connection error also shows.

I checked Google's Google Analytics status and there were no problems at this time.


Google Analytics

The issue does not happen with this:

<script>
    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
    ga('create', 'UA-12345678-1', 'auto');
    ga('send', 'pageview');
    ga('set', 'anonymizeIp', true);
</script>

<script async defer src="https://www.google-analytics.com/analytics.js"></script>

For this code I see a call to Google Analytics:

https://www.google-analytics.com/collect?v=1&_v=j66&aip=1&a=1122917586&t=timing&_s=2&dl=http%3A%2F%2Flocalhost%2F&ul=nl&de=UTF-8.....

This happens to me in the same browser on the same computer, so I think we can rule out that my computer or browser has trouble connecting to www.google-analytics.com.

@jehna
Copy link
Owner

jehna commented Jan 12, 2018

Hey

Thank you for the detailed bug report.

At least my own blog (running ga-lite latest version) seems to report analytics to Google normally (I don't see any decrease in statistics).

Pingdom's tool does not work properly with ga-lite (or better said with the Google's measurement protocol API). It was discussed in issue #50.

I can check further on the weekend. Could you double check that your browser does not have the "do not track" setting enabled?

So navigator.doNotTrack should be false.

@Jos512
Copy link
Author

Jos512 commented Jan 13, 2018

Thanks Jehna, it was indeed the 'do not track' setting. When I disable that option, ga-lite makes a call to www.google-analytics.com as expected.

I got confused here because the regular analytics.js file from Google Analytics themselves doesn't take that setting into consideration. (Which is actually a documented feature, so the project couldn't be doing it better. I just had to actually understand it. 😄 )

Thanks for your help!

@Jos512 Jos512 closed this as completed Jan 13, 2018
@Jos512 Jos512 changed the title Does it work for you? ga-lite doesn't track when Google Analytics does ('Do not track' difference) Jan 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants