jehna / ga-lite Goto Github PK
View Code? Open in Web Editor NEWSmall, cacheable and open version of Google Analytics JS client
License: MIT License
Small, cacheable and open version of Google Analytics JS client
License: MIT License
I downloaded the minified js file so i could serve it from my server for performance and I in Google Chrome console reports an error in the syntax. I was unable to determine why this has an error.
Hi Jesse, I know that its not an issue, but I'm not sure what I'm doing wrong!?
I have wordpress site and I'm required to make the Google pagespeed 100/100, so I've searched everywhere and came across your plugin.
As you mentioned I copied the code you posted to the body of my site and I added the google analytics tracking code which is UA-XXXXXXXX-X. The score is still the same, can you please tell me if theres something I'm missing or should do ?
Thanks a lot
I use latest ga-lite and PageSpeed is still reporting to leverage browser caching with analytics.js ... what am I doing wrong?
http://prntscr.com/it3mzj
https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fwww.defendanimals.com%2F&tab=desktop
Original GA is reported as Leverage browser caching on both GT Metrics and pingdom ,
with ga-lite the hit is moved from PageSpeed to YSlow so you are getting hit either way
http://i.prntscr.com/6EctdfeoQnGYtfyyOejfcw.png
Scores with Google Analytics
Speed: 98
YSlow: 86
with ga-lite
Speed: 99
YSlow: 84
If I perform a Google mobile friendly test on a website that uses ga-lite
, I get the following error message:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/
Here's an example of such a mobile friendliness report.
The problem looks to be caused by this line.
Hi there (I hope this is the right place to raise issues),
I was using v1 of ga-lite and was extremely pleased.
I admit I don't check my analytics too often, and yesterday I've found out Google says my site is not using the needed code for several months now. So I came back here and found out there's a new version.
I've replaced v1 code with the v2 one, but I'm getting a red result from the Google Tag Assistant's Chrome addon, with the following errors:
Now, I can realize the missing js ofcourse hence the 2nd error should be ignored, as we're using galite.js, but can the 1st error be ignored as well?
TIA,
David.
PS: This is the site I'm using ga-lite on is if you need to look at the code.
How would I explicitly fire the event some time after the page load ?
If you process the current minified version through Closure Compiler and then Ajax Minifier the file size is further reduced from 1,111 bytes to 1,033 bytes.
As far as I understand, there are no side effects of the process.
Is there any reason not to use these compression methods for ga-lite?
ReferenceError: window is not defined
Was introduced with verison 2.0.4.
The version 2.0 doesn't yet support fully the app/screen tracking.
https://developers.google.com/analytics/devguides/collection/analyticsjs/screens
Hi
just a great code to get better results in Page Insights.
Is it possible to add the option to track Ecommerce conversions ? Because it is not getting any data from client purchases.
I want to know if its possible too for the Google Addon "Block Yourself from analytics" to block the traffic from the addon , because i do many changes and test during the day in my store and it's always getting traffic from that location that i do the changes.
Many thanks ,
waiting your feedback
Should include some kind of bot to automatically build the versions, like Rultor.
This is, so the correct versioning of the files would not be eligible for a human error
Version 2 does not implement the analytics.js plugin API:
https://developers.google.com/analytics/devguides/collection/analyticsjs/writing-plugins
Hi there, trying to get ga-lite running via RequireJS. Have this code in my main.js file (obviously my-ua-account-no
is really my account number):
require(['galite'], function()
{
var galite = galite || {};
galite.UA = 'my-ua-account-no';
galite.anonymizeIp = true;
});
It seems when the request is made to https://www.google-analytics.com/collect?
the tid
value is undefined
- any idea why this is happening?
So this project can be easily extended, the library should expose a public API that a user can call.
Similarly like the official analytics.js exposes the ga()
function, ga-lite should have some kind of public API that can be called when an event has fired.
Originally I had this error: #32
Now using v2 I am seeing this error instead:
So something is still wrong.
src{https://cdnjs.cloudflare.com/ajax/libs/ga-lite/2.0.1/ga-lite.min.js}
window.galite=window.galite||function(){(galite.q=galite.q||[]).push(arguments)};
galite('create', 'xxxx', 'auto');
galite('send', 'pageview');
galite('set', 'anonymizeIp', true);
I'm trying to embedding the script directly in html and then call it - but nothing seems to happen.
Did i miss something?
this https://github.com/jehna/ga-lite/blob/master/src/ga-lite.js#L74
var paramsStr = '';
for (var key in params) {
paramsStr = '&' + key + '=' + encodeURIComponent(params[key]);
}
should be
var paramsStr = '';
for (var key in params) {
paramsStr += '&' + key + '=' + encodeURIComponent(params[key]);
}
note the +=
concatenation
also fixed in here #21
Google recently started recommending one to track using gtag.js instead of analytics.js and I'm curious how this affects this project, if it affects it at all.
More information: https://developers.google.com/analytics/devguides/collection/gtagjs/migration
Asking this because the recommended way to install ga-lite
from the README is a script similar to the old ways of setting up Google Analytics on our pages.
Add a function to anonymize ip adress. Guess should be something like
ga('create', 'UA-XXXXXXX-X', 'website.de');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
Version 2 does not implement the analytics.js Tasks API yet:
https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks
Implement the Navigator.doNotTrack API to avoid unnecessary requests to the Google Analytics measurement protocol endpoint
Custom dimensions might not work properly in version 2 yet.
https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
Hi,
Under chrome everything's fine but under Firefow we see this error :
Erreur : NS_ERROR_FAILURE:
Fichier source : https://cdn.jsdelivr.net/ga-lite/latest/ga-lite.min.js
Ligne : 1
The 1.x version is currently in use with 43M hits/month from jsDelivr. This provides us with an issue, since the old jsDelivr link did have the latest
tag as default – so upgrading to 2.0 version would brake thousands of analytics on websites.
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
.
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/[email protected]/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.
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
.
The v1
implemented the onunload event by default to correct the time spent on page (especially on bounces).
The original code:
var pageLoadedTimestamp = new Date().getTime();
/**
* Note:
* unload event does not fire on:
* - Android chrome on tab closing
*/
window.addEventListener(
'unload',
eventBuilder(
'timing',
{
'utc': 'JS Dependencies',
'utv': 'unload',
'utt': (new Date().getTime() - pageLoadedTimestamp)
}
)
);
HI,
I want to embed ID UA-71257141-1 and UA-71257141-10 to my web
I have a privacy concern about the code-snippet. Even if it's following browsers tracking-choice, it is not enough for european websites, to use the code.
According to the GDPR User has to get a choice, to manually disable Tracking.
I used GA-Lite within a website, and discovered, that the opt-out-plugin does not work.
Can anybody help, how to change the opt-out-cookie-code, that it will work with GDPR and go-lite? Thanks!
// Set to the same value as the web property used on the site
var gaProperty = 'UA-XXXXXXX-X';
// Disable tracking if the opt-out cookie exists.
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}
// Opt-out function for Google Analytics
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
}
</script>
Hi,
What exactly I don't get using this library instead of official?
I can see what I get, but not what I don't get.
Thanks!
Remove Grunt, as Webpack provides many enhancements out of the box to Grunt.
Please, how do I enable multiple tracking codes with GA-Lite?
Thanks!
The inline call to http://www.google-analytics.com/collect
should use no protocol and just //
so that it uses the protocol of the website that it is being used on.
Is reporting connection error
It would be nice if one could send own custom events, e.g. on button click etc.
From what I see that should be possible by making the eventBuilder publicly available?
This project should be added to a CDN, like https://github.com/cdnjs/cdnjs
Hi there!
Thank you for you module!
I'd like to know hot to set the session timeout with ES6?
Now I make it in such way:
<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-xxx-1', 'auto');
ga('send', 'pageview');
setTimeout(function() {
ga("send", "event", "New Visitor", location.pathname)
}, 15000);
</script>
If your browser has cookies disabled, using localStorage
throws an error that crashes ga-lite.
ga-lite should be able to work even without localstorage.
Hi,
Awesome project! Just noticing when trying to add the below conversion tags that it doesn't seem to work.
I know that you change 'gtag' to 'galite' in the below examples, but I just get errors in the console when trying to run these conversion tags.
Firstly AdWords ask you to add a tag like this if you already have analytics running (which I do as it's galite analytics).
But basically having no joy with the below set up as per the screenshot:
https://www.screencast.com/t/lUPDs4xS
And the raw code here for reference:
`<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-XXXXXXXX-X', 'auto');
galite('send', 'pageview');
galite('config', 'AW-930415418');
galite('config', 'AW-930415418/n5jDCMeornAQuobUuwM', {
'phone_conversion_number': '02 9939 xxxx'
});
</script>`
Any ideas please?
Thanks.
Richard
ga-lite does not currently report page load times.
Implement page speed timings:
https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings
Using ga-lite, and testing my site from tools.pingdom.com results in a error for the following URL:
Any explanation for this?
Is it something on my site or is it something in the ga-lite code?
As stated in this article is it posible to make this library to send all collect requests to a custom endpoint or proxy?
How about adding something like "Alternative async tracking snippet" from https://developers.google.com/analytics/devguides/collection/analyticsjs/ to docs?
I believe it could look something like this:
<script>
window.galite=window.galite||function(){(galite.q=galite.q||[]).push(arguments)};
galite('create', 'UA-XXXXX-Y', 'auto');
galite('send', 'pageview');
</script>
<script async src="https://cdn.jsdelivr.net/npm/ga-lite@2/dist/ga-lite.min.js"></script>
(caution: didn't test this)
Also, why doesn't it save the time on creating the placeholder galite
fucntion? Does it not report page load time?
This plugin gets excellent reviews, but I've just realised that I am going to miss out because I've converted my WordPress to Native AMP on every page and no longer have regular Google analytics.
Will this be possible, at some point, please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.