Quantcast
Channel: Matomo forums - Latest topics
Viewing all articles
Browse latest Browse all 13999

How can I track clicks on all internal links without using onclick? (menu links, text links, button clicks)

$
0
0

@Clink wrote:

Hello,

I know I can insert onclick e.g.:

<a href="mysite.com/page2" onclick="javascript:_paq.push(['trackEvent', 'Click', 'PageID']);">Click here</a>

but isn't there an easier way to apply event tracking to all links? I also found this advice "you're better off not using onClick at all and attaching the event handler to the DOM node through your JS code. This is known as unobtrusive javascript." I'm not sure how to do that - I just want to be able to track clicks on all links so I can see what people are doing on my site. It must work on all devices. It would be nice if I didn't had to manually change every single link on all my pages, menus etc.

How do I do it and is it possible to use the link text (e.g. "click here to sign up", "read more here" etc.) to identify each link? (so there will be an event for each link).

I have looked for a solution for several days, but I guess I'm not smart enough... any help is appreciated, thanks.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 13999

Trending Articles