Learn business growth with Google Analytics 4 Forums Google Analytics 4 How can I track hover events for multiple elements in this code? Reply To: How can I track hover events for multiple elements in this code?

  • Alexander

    Member
    23 January 2023 at 9:20 am

    Yes, you have two concerns: tracking multiple images and tracking images based solely on their alt text. To accommodate multiple images, you can include all the selectors (class names or IDs) separated by commas when you call the function. As for tracking images by alt text, you’ll have to modify the code a bit. Currently, the code uses the element’s class or id to identify it. You can add an extra line of code to grab its alt text instead when no class or id is available, and then use that to track the hover event. So, it’s totally possible to adjust this code to meet your needs.