lifadev / archive_privera

Use the tools you know. Respect users' privacy. Forget cookie consents. Comply with GDPR, ePrivacy, COPPA, CalOPPA, PECR, PIPEDA, CASL; you name it.
https://privera.io
Apache License 2.0
25 stars 1 forks source link

API to manually send page views? #5

Open jakezien opened 3 years ago

jakezien commented 3 years ago

I'm trying Privera on a Gatsby site, so the script is only run once, on initial page load. Is there a way to send ga events through Privera, so I can react to route updates?

fsenart commented 3 years ago

The current collector doesn't provide a way to send custom events. However, it's definitely possible to add this kind of feature in a future version. Also, can you please tell me if you only need to send page views on route change or you actually need custom events? In effect, we can go toward a more elaborate collector, which will use the browser history API and automatically send page views so that you don't have to do it by yourself.

jakezien commented 3 years ago

Thanks for the thoughtful reply!

Right now I only need page views on route change; custom events are a nice-to-have but not critical. At the moment, I've hacked a solution to route changes by hosting a copy of the script myself, giving the anonymous IIFE a name, and calling it from onRouteUpdate in Gatsby's browser API (gatsby-browser.js). I found that I also had to wrap it in a brief setTimeOut in order to get the route to match the page title — I was seeing results in Google with the new route, but previous page title.