Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ log explorer views to google analytics (#4098)
Resolves #4094 ## Summary A view event is logged to Google Analytics when an Explorer is rendered and when the view is changed. ## Details - A view event is logged if Explorer is scrolled into view so that we only log an event when an Explorer has actually been looked at - We also log an event when the user updates the view Logged events are of the following shape: ``` { "event": "owid.explorer_view", "explorerPath": "/explorers/democracy", "explorerView": JSON.stringify({ Dataset: "Polity", Metric: "Democracy", "Sub-metric": "Main index" }) } ``` ## Testing I tested this code by console logging when an event is fired, but I haven't checked to see if these events actually end up in GA. - Explorer page: http://staging-site-log-explorer-views/explorers/democracy - [x] Should log one view event on page load - [x] Should log an event when the view is changed - Topic page: http://staging-site-log-explorer-views/democracy - [x] Should log an event when the explorer is scrolled into view - [x] Should log an event when the view is changed - [x] Should not log another event when the explorer is scrolled out of view and then again into view - [x] Should not log an event for the embedded explorer
- Loading branch information