Solved

How to use aria labels as part of snapshot properties?

  • 22 August 2023
  • 2 replies
  • 124 views

Badge +1

I’ve created an event tracking when a book is downloaded from our site. I want to add a snapshot property to capture the book name. The closest I have found referencing the book name is the aria-label but I can’t figure out how to use that as part of the property definition.

My event is defined as a click on button.Button-module_root__8RX49 with Target Text equals Download.

Here’s a screenshot from our site:

 

 

icon

Best answer by ALabs I Bhupender 23 August 2023, 08:45

View original

2 replies

Userlevel 3
Badge +1

Hi,

You can use a snapshot to capture the value of the “aria-label” data attribute. To do so, you will need to add a snapshot “to value of javascript” to your event definition, and use the javascript

event.target.closest("button[aria-label]").getAttribute("aria-label")

This will start capturing the value of the aria-label of the element clicked.

Here is an example:

 

Note that once your snapshot is saved, it will take 2-10 minutes for that change to show up in your heap.js file. Once heap.js is updated, it should show up in the dashboard immediately after it’s captured. You may validate it in live data feed, after few refreshes on your website page and Heap page.

Hope this helps!

Badge +1

This worked perfectly, thank you!!

I had been trying something similar base don other forum posts but was missing the crucial “button” in front of the first “[aria-label]”.

Reply