Hi, you made me curious and I just tried to implement it on my own site:
This is a minimal working example, I hope you get the idea how to implement it yourself I added a javascript handler, which execute the piwik trackEvent function.
<a href="tel:+123456789" class="phoneLink">Call me</a>
<script>
$(".phoneLink").on("click", function () {
_paq.push(['trackEvent', 'contact', 'clicked phone number', ]);
});
</script>
Of course you can also write it in plain javascript without jQuery.
This tracks all clicks on the phone number as events, for more sophisticated statistics (which phone numbers get clicked most often, usw.) you’ll need to use CustomDimensions .
Update:
a bit more sophisticated example:
$("a[href^='tel:']").on("click", function (e) {
_paq.push(['trackEvent', 'contactform', 'called', this.href]);
});
And while we are on it we an use the same concept to track mailto:
links:
$("a[href^='mailto:']").on("click", function (e) {
_paq.push(['trackEvent', 'contactform', 'mail sent', this.href]);
});
If you are not using jQuery: (thanks to @Patrice)
document.querySelector("a[href^='tel:']").addEventListener('click', function (e) {
_paq.push(['trackEvent', 'contact', 'called this phone number', this.href]);
});