๐ Hello, team! Im started using MP for my organisation and Im new to the tool and still learning. I got stuck on Auto Element Click event where I couldn't see $element_text property and it values for each click event. I enabled autocapture true for click events. Still I couldn't see, can anyone please help me on this?
Below is my code structure
mixpanel.init('', {
autocapture: {
pageview: false,
click: true,
input: true,
scroll: true,
submit: true
},
});
mixpanel.register({
my code here
});
// Tried this to add the $element_text since values not showing on default
$('a').on('click', function (e) {
const anchorText = $(this).text().trim();
const href = $(this).attr('href');
// Skip tracking if it's a hash or JS-only link
if (!href || href.startsWith('#') || href.startsWith('javascript:')) {
return;
}
// Stop default behavior to allow event to send
e.preventDefault();
// Track the anchor click manually
mixpanel.track('Anchor Clicked', {
'Anchor Text': anchorText,
'Href': href
});
// Delay navigation just enough for Mixpanel to send the event
setTimeout(() => {
window.location.href = href;
}, 200); // You can increase to 300ms if needed
});