I'm following this tutorial trying to add tracking to a download button in a repeater dataset. I can't figure out why I'm getting this error on the bottom line getCurrentItem(). Any help would be appreciated.
import wixWindow from 'wix-window'; export function downloadButton_click(event) { wixWindow.trackEvent("CustomEvent", { "event": "Document Download", "eventCategory": "Downloads", "eventAction": "Download", "eventLabel": $w('#DownloadWPButton').getCurrentItem().title } ); }
Screenshot:
The getCurrentItem() only works on a Dataset element on the page.
https://www.wix.com/velo/reference/wix-dataset/dataset/getcurrentitem
Also is this button in a repeater? If so this would have to be done with the onItemReady for the repeater and then set the eventLabel to itemData.title.
https://www.wix.com/velo/reference/$w/repeater/onitemready