-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ log grapher views to google analytics (#4076)
Resolves #3834 ## Summary A view event is logged to Google Analytics when Grapher is rendered. ## Details - A view event is logged if Grapher is scrolled into view so that we only log an event when a Grapher chart has actually been looked at - Grapher only logs a view event if it has a slug - Explorers used to pass their slug to Grapher for no good reason -> has been removed - Mdims used to pass a DUMMY slug to Graphers as a workaround -> has been removed Logged events are of the following shape: ``` { "event": "owid.grapher_view", "grapherPath": "/grapher/share-of-population-in-extreme-poverty" } ``` or, for multi-dim data pages, ``` { "event": "owid.grapher_view", "grapherPath": "/grapher/mdd-demo-energy", "grapherView": { "source": "all", "metric": "total" } } ``` - Bobbie said it didn't matter if `grapherView` is stringified or not, so I went with the richer format - The keys in `grapherView` (e.g. `source`, `metric`) are always complete and sorted If I understand correctly, Google Tag Manager always includes the current page, so there is no need to explicitly pass that for embedded Graphers. #### Share menu refactor - The reason explorers and mdims pass a slug into Grapher is that a missing slug disables the share menu - This didn't make much sense (unless I'm missing something), so I refactored the share menu such that the share menu button is hidden when the menu wouldn't have any items (which depends on the canonical and edit URLs) ## 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. (I asked Bobbie how to do this and will check later today) - Grapher/data page: http://staging-site-log-grapher-views/grapher/life-expectancy - [x] Should log one view event - Article: http://staging-site-log-grapher-views/how-has-income-inequality-within-countries-evolved-over-the-past-century - [x] Should log a view event when Grapher is scrolled into view, but not earlier - Multi-dim data page: http://staging-site-log-grapher-views/admin/grapher/mdd-demo-energy - [x] Should log an event on page load - [x] Should log an event on changing the view - Homepage: http://staging-site-log-grapher-views - [x] Should log an event when scrolling to the first key indicator - [x] Should log an event when opening another key indicator, but not earlier - Topic page: http://staging-site-log-grapher-views/poverty - [x] Should log an event when clicking on a key insight with a chart, but not earlier - [x] Should log an event on scrolling to the All charts section, but not earlier - [x] Should log an event on clicking the "Next" button in the All charts block, but not earlier - [x] Should not log an event for the embedded explorer - Explorer page: http://staging-site-log-grapher-views/explorers/air-pollution - [x] Should not log an event ## Caveats - In the All charts block, an event is logged when going back to a chart that has already been viewed - In the Key indicator block, no event is logged when opening a key indicator that has been opened before Not sure what's the right thing to do here, but I guess it doesn't matter that much and both are fine?
- Loading branch information
1 parent
fc61042
commit c2d1713
Showing
7 changed files
with
102 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,3 @@ $zindex-ControlsFooter: 2; | |
} | ||
} | ||
} | ||
|
||
.ShareMenu.disabled a { | ||
pointer-events: none; | ||
opacity: 0.3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters