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
6938/feature/google analytics html for facet #7042
6938/feature/google analytics html for facet #7042
Conversation
I doubt that web.py will support match / case syntax in html. |
Do we NEED match / case or could this be done with normal dict lookup? def add_track(key: str) -> str:
"""
KeyError will be raised if key is not in the following dict.
"""
facets = {
"has_fulltext": "Ebook",
"author_key": "Author",
"subject_facet": "Subjects",
"person_facet": "People",
"place_facet": "Places",
"time_facet": "Times",
"first_publish_year": "FirstPublished",
"publisher_facet": "Publisher",
"language_facet": "Language",
}
return f"SearchFacet|{facets[key]}" |
Most likely not, I would agree that your version looks much better. |
Modified google analytics tracking html according to code from @cclauss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! Confirmed the tags now appear on testing.openlibrary.org . Thank you @yoonmgyg !
Closes #6938
Google analytics attributes are added to search facets, allowing for the tracking of their popularity when clicked.
Technical
work_search.html now contains the data-ol-link-track attribute when headers are clicked, which uses the add_track function to get the value.
Testing
I'm not entirely sure how it can be verified, but it can be tested by using the search function in the website and clicking on one of the facets provided for the search.
Screenshot
Stakeholders
@cdrini