jehna / ga-lite

Small, cacheable and open version of Google Analytics JS client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Universal Analytics (GA3) and GA4 same time

nfn opened this issue · comments

commented

Hi

Can ga-lite be used for GA3 and GA4 at the same time (see bellow)?
Is the script able to log GA4?

Thanks

(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('create', 'G-XXXXXXXX', 'auto');
galite('send', 'pageview');
</script>```

Unfortunately no. ga-lite uses the measurement protocol which only works for V3.
There is an alpha API for the V4 that you could take a look. If it works similarly to the V3, then switching URLs to the new protocol should be straightforward.

If you're interested to take a look I'll be happy to accept pull requests!

Closing as duplicate of #205