Getting and displaying link ID in statistics

Hello,

I would like to know if it is possible to get the link ID, which is defined on my site and display it in the statistics?
The links are built as follows:

<a class="overlay" href="<?php echo $row['LINK']; ?>" target="_blank" id="<?php echo $row['NAME']; ?>"></a>

I want to get the “NAME” part and show it in the statistics.

Thanks in advance.

Hi @tvelkov
How do you track?

I am tracking with the javascript code. I tried the following script:

<script type="text/javascript">
  function trackMatomoLinkClick(linkId) {
  _paq.push(['trackEvent', 'Site Click', 'Click', linkId]);
}
</script>

but I’m not sure how to get the link id to be displayed in the dashboard.

Hi @tvelkov
You should do:

<a class="overlay"
   href="<?php echo $row['LINK']; ?>"
   target="_blank"
   id="<?php echo $row['NAME']; ?>"
   onclick="trackMatomoLinkClick('<?php echo $row['NAME']; ?>');return true;">Link label</a>