cityofaustin / grackl

A bird's eye view of Digital Projects at the City of Austin
https://grackle.austintexas.io/
MIT License
11 stars 3 forks source link

Add page route changes to Google Analytics reporting #117

Closed mateoclarke closed 6 years ago

mateoclarke commented 6 years ago

Problem

We have enabled Google Analytics to log user search, url parameters that include ?search=some_term. However, it appears these events are not being sent to GA from the client and these searches are not getting logged.

Potential Solutions

I have a hunch that it has to do with the way URL parameters work in Gatsby. In order to save requests, it has its own routing like a single page javascript app. So changing the url might never notify the GA. I think there is some manual coding we need to do to trigger GA submits on certain events.

@toribr found this thread on the Gatsby repo: https://github.com/gatsbyjs/gatsby/issues/64

onRouteChange seems like a great place to start.