Piwik track click on email address and phone number

Hallo,

i use piwik since a few years and i love it, but now i want to track click on email address and phone number on desktop and mobile devices.

How is it possible?

Florian

Hey!

You just have to trigger JavaScript methods for these links, like this for example:

<a href="tel:888888" onClick="javascript:_paq.push(['setCustomVariable', 1, 'name', 'value', 'page']);">Item</a>

For tracking phones I think it would be best to use trackEvent, see guide with similar examples here

1 Like

HI Michael, how do i implement this in the code?

Hey Darryl,

You need to either modify your links to include “onClick” attribute, that will include _paq.push statement of your choice. For example for custom event you need to include
javascript:_paq.push(['trackEvent', "Some category", "Some action","Some_name"]);.

You can also add separate javascript to handle that, or use your Tag Manager to detect click and then run the _paq code on click:
<script> _paq.push(['trackEvent', "Some category", "Some action","Some_name"]); </script>

Hi Michael,

is this right

Hi Darryl,

This is not the way - by doing that you would have those event tracked on each pageview. This _paq code needs to be executed upon actual interaction. Check out this guide, it describes everything you need :slight_smile: https://matomo.org/blog/2019/06/easily-track-events-within-matomo-analytics-thanks-to-matomo-tag-manager/

1 Like