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

6938/feature/google analytics html for facet #7042

Conversation

yoonmgyg
Copy link
Contributor

@yoonmgyg yoonmgyg commented Oct 2, 2022

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

2022-10-02_01-34

Stakeholders

@cdrini

@cclauss
Copy link
Collaborator

cclauss commented Oct 2, 2022

I doubt that web.py will support match / case syntax in html.

@cclauss
Copy link
Collaborator

cclauss commented Oct 2, 2022

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]}"

@yoonmgyg
Copy link
Contributor Author

yoonmgyg commented Oct 2, 2022

Most likely not, I would agree that your version looks much better.

@cdrini cdrini self-assigned this Oct 4, 2022
@cdrini
Copy link
Collaborator

cdrini commented Oct 4, 2022

Thanks @yoonmgyg ! I agree with @cclauss ' suggestion :) Could you please update your solution to use that approach?

@cdrini cdrini added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Oct 4, 2022
Modified google analytics tracking html according to code from @cclauss
Copy link
Collaborator

@cdrini cdrini left a 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 !

@cdrini cdrini merged commit 60f29cd into internetarchive:master Oct 4, 2022
@cdrini cdrini added On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing and removed Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] labels Oct 4, 2022
@jimchamp jimchamp removed the On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing label Apr 2, 2024
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.

Add Google analytics tracking to search facets
4 participants