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

✨ log explorer views to google analytics #4098

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Oct 31, 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.

@sophiamersmann sophiamersmann marked this pull request as ready for review October 31, 2024 15:39
@owidbot
Copy link
Contributor

owidbot commented Oct 31, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-log-explorer-views

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-10-31 15:48:38 UTC
Execution time: 1.23 seconds

Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice work!

@sophiamersmann
Copy link
Member Author

Thank you for the review!

Copy link
Member Author

sophiamersmann commented Nov 1, 2024

Merge activity

  • Nov 1, 11:16 AM EDT: A user started a stack merge that includes this pull request via Graphite.
  • Nov 1, 11:20 AM EDT: Graphite rebased this pull request as part of a merge.
  • Nov 1, 11:21 AM EDT: A user merged this pull request with Graphite.

@sophiamersmann sophiamersmann changed the base branch from log-grapher-views to graphite-base/4098 November 1, 2024 15:16
@sophiamersmann sophiamersmann changed the base branch from graphite-base/4098 to master November 1, 2024 15:18
@sophiamersmann sophiamersmann merged commit ea3e88e into master Nov 1, 2024
13 of 15 checks passed
@sophiamersmann sophiamersmann deleted the log-explorer-views branch November 1, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a custom event for every chart view in explorers
3 participants