Hide Javascript tracking and use log analysis only

We would like to use log analysis only (this works great for us). So we want to hide references to JavaScript tracking in the site owner UI, and prevent site owners from using JS tracking if they do figure it out.

I can easily restrict access to /matomo.js, but the Javascript tracking instructions in the UI and emailed out are the hard part.

Is there a config or a plugin to hide this stuff?

Hi,

There is no built-in way to change this, but you could write a plugin that modifies the templates and texts to what you would like to have displayed.

Thanks Lukas - some RewriteRule’s plus a theme is indeed what I ended up doing. For future travellers, this is not well tested and might break your legs:

Redirects/Rewrites:

            <IfModule mod_rewrite.c>
              #Prevent JS- and image-based stats tracking requests,
              #but allow other API requests.
              RewriteEngine On
              RewriteCond %{REQUEST_URI} ^/?matomo\.php$ [NC]
              RewriteCond %{QUERY_STRING} ^([^&]*&)*idsite=([^&]+) [NC]
              RewriteCond %{QUERY_STRING} ^([^&]*&)*rec=([^&]+) [NC]
              RewriteCond %{QUERY_STRING} !^([^&]*&)*module=([^&]+) [NC]
              RewriteCond %{QUERY_STRING} !^([^&]*&)*action=([^&]+) [NC]
              RewriteCond %{QUERY_STRING} !^([^&]*&)*action_name=([^&]+) [NC]
              RewriteRule .* - [F,L]
            </IfModule>

JS:

console.log('Theme: Theme loaded');

function my_getParameterByName( name ){
    var regexS = "[\\?&]"+name+"=([^&#]*)", 
  regex = new RegExp( regexS ),
  results = regex.exec( window.location.search );
  if( results == null ){
    return "";
  } else{
    return decodeURIComponent(results[1].replace(/\+/g, " "));
  }
}

var my_module = my_getParameterByName('module').toUpperCase();
var my_action = my_getParameterByName('action').toUpperCase();
if(
    (my_module === 'API'.toUpperCase() && my_action === 'listAllAPI'.toUpperCase()) ||
    (!piwik.hasSuperUserAccess && my_module === 'CoreAdminHome'.toUpperCase() && my_action === 'trackingCodeGenerator'.toUpperCase()
    )
) {
    console.log('Theme: We should redirect from this page');
    // Hide the API page content.
    $( document ).ready(function() {
        // Platform > API.
        $('.api-list').remove();
        // Measureables > Tracking code.
        $('#content').remove();
    });
    // Do the redirect.
    window.location.replace('/');
}

$( document ).ready(function() {
    var elt=$('#secondNavBar li:contains("Platform")');
    if(elt && elt.length) {
      console.log('Theme: We should remove the Platform menu item');
      // Hide the Platform menu bc I do not want to encourage use of the API directly.
      elt.remove();
    }

    elt=$('#secondNavBar li:contains("Measurables")').remove();
    if(!piwik.hasSuperUserAccess && elt && elt.length) {
      console.log('Theme: We should remove the Measurables menu item');
      // Hide the Measurables menu bc I do not want to encourage use of JS tracking.
      elt.remove();
    }
});
1 Like