Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a custom event for every chart view in explorers #4094

Closed
sophiamersmann opened this issue Oct 30, 2024 · 0 comments · Fixed by #4098
Closed

Create a custom event for every chart view in explorers #4094

sophiamersmann opened this issue Oct 30, 2024 · 0 comments · Fixed by #4098
Assignees

Comments

@sophiamersmann
Copy link
Member

We want to log custom view events to GA for explorers, similar to how it's done for Grapher and Data pages in #4076.

@sophiamersmann sophiamersmann self-assigned this Oct 30, 2024
sophiamersmann added a commit that referenced this issue Nov 1, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant