Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

API to manually send page views? #5

Open
jakezien opened this issue May 16, 2021 · 2 comments
Open

API to manually send page views? #5

jakezien opened this issue May 16, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@jakezien
Copy link

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 fsenart added the enhancement New feature or request label May 17, 2021
@fsenart
Copy link
Contributor

fsenart commented May 17, 2021

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
Copy link
Author

jakezien commented May 17, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants