Piwik: track telephone and email links

It's possible to link to telephone numbers which can easily be dialed on mobile devices. But piwik automatically just tracks links that use the http protocol.

In this case we need to set custom variables that track the click on the telephone or email link. With the Silverstripe Piwik module it's pretty simple. Just put this code in your Piwik.ss template before the closing </script> tag:

	jQuery(document).ready(function($) {
            _paq.push(['setCustomVariable',1,'Share By Email','Email='+this.href.replace(/^mailto:/i,'') + ' /Page = ' +  location.href,'page']);
            _paq.push(['setCustomVariable',1,'Call Telephone','Tel='+this.href.replace(/^tel:/i,'') + ' /Page = ' +  location.href,'page']);

Disclaimer: code modified after this example.

Rate this post

Post your comment


No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments