@tad-lispy opened this Issue on May 4th 2019

Hi! Thank you for making this code and your service available to us.

I'm a new user and I'm quite excited about your platform. I'm trying to integrate it into several websites. I'd like to file a bug report and share my initial experience.

Steps I took so far

  1. I've added the website to the dashboard and copied the JS code to the head section of my HTML.

  2. I've run the local web server to test if it works

    I'm using Parcel to compile and preprocess the assets, so the local address was http://localhost:1234/ . The visit was immediately registered in the dashboard 👍

  3. I've pushed the code and my CI deployed it to the production site.

  4. I've tried visiting it from different browsers, devices and networks

    No visits were registered 🤕 There was no indication in the dashboard or the browser console. I saw that the inline script works because the other (remote) script tag was injected into the DOM.

What seems to be the problem

After about an hour of investigation it seems to me that the problem is related to pre-processing of the inline code (the one I copied and pasted). When compiled in development mode it is not minified and everything works as expected. When compiled for production it gets minified and _paq variable gets renamed. Then the other (remote) script doesn't work - but without any exception, it just doesnt do anything. This is really bad first impression.

What should have happened

Obviously the code should just work, but if it doesn't, there should be some indication as to why. Either an exception in the browser console or (better) a warning in the dashboard. It seems technically possible. The web app could fetch and inspect the configured website and give some info about the state (is there a script? does it send events? does it have correct site id?)

It is acceptable that the code you provide should not be minified (alas why not?). The real problem is lack of feedback from the system.

The workaround

For the minification problem the workaround seems to be changing the first line of the script from:

var _paq = window._paq || [];


window._paq = window._paq || [];

But again, bigger problem is lack of any indication that something is wrong.

@tsteur commented on May 5th 2019 Member

In general the tracker is already minified and I would recommend you don't minify it again. You could exclude it in a list somewhere depending how you minify.

I suppose we would likely merge it if you created a PR. There's in theory a risk we're breaking something though so maybe we would do this only with Matomo 4. In theory, behaviour may slightly change if someone did something like

function () {
var _paq= [];_paq.push(..);

// then the matomo tracking code

You'd think maybe nobody does it, but with hundred thousands of users, and maybe someone wanting to avoid a global variable, this could be the case.

Powered by GitHub Issue Mirror