tracking to matomo

This commit is contained in:
jessop 2020-06-08 21:29:37 -04:00 committed by Jeremy Kauffman
parent 16085c8aee
commit 59b4abff16
2 changed files with 20 additions and 2 deletions

View file

@ -22,6 +22,20 @@
fbq('track', '<?php echo Response::getFacebookPixelAnalyticsType() ?>');
</script>
<script type="text/javascript">
var _paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['setLinkTrackingTimer', 750]); // increase to 750 milliseconds
(function() {
var u="https://analytics.lbry.com/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '2']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<?php else: ?>
<script>
window.ga = function() {};

View file

@ -8,8 +8,12 @@ $(document).ready(function() {
function onAnchorClick() {
var anchor = $(this);
if (anchor.data('analytics-category') && anchor.data('analytics-action') && anchor.data('analytics-label') && window.ga) {
ga('send', 'event', anchor.data('analytics-category'), anchor.data('analytics-action'), anchor.data('analytics-label'));
if (anchor.data()['analyticsCategory'] && anchor.data()['analyticsAction'] && anchor.data()['analyticsLabel'] && window.ga) {
ga('send', 'event', anchor.data()['analyticsCategory'], anchor.data()['analyticsAction'], anchor.data()['analyticsLabel']);
}
if (anchor.data()['analyticsCategory'] && anchor.data()['analyticsAction'] && anchor.data()['analyticsLabel'] && window._paq) {
_paq.push(['trackEvent', anchor.data()['analyticsCategory'], anchor.data()['analyticsAction'], anchor.data()['analyticsLabel']]);
}
}
});