Tracking Code - tracker url does not appear to be getting set

Hello,

I’ve just installed Piwik, but I am not getting page tracking data. I have copied the tracking code directly from my administration page.

From my browser’s developer tools (both Firefox and Chrome), I see that the GET request is going to the same server as the loaded page, instead of the analytics server. It looks like the tracker URL is not being set.

Page to Track: webApp
Piwik Server: analyticsServer

Tracking Code on https://webapp

var _paq = _paq || ;
_paq.push([‘trackPageView’]);
_paq.push([‘enableLinkTracking’]);
(function() {
var u=“//analyticsServer/analytics/”;
_paq.push([‘setTrackerUrl’, u+‘piwik.php’]);
_paq.push([‘setSiteId’, 1]);
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+‘piwik.js’; s.parentNode.insertBefore(g,s);
})();

The net tab in developer tools shows:

https://webapp/?action_name=[...]

Which results in an error, because the tracking code should be going to:

https://analyticsServer/analytics/piwik.php?action_name=[...]

I’ve just upgraded from 2.9 to 2.10, both had this issue.

In the console when I check the Piwik object’s tracking URL, it returns a blank (when I switch to js/piwik.js, the unminimized code). I’m not sure if this really indicates anything though:

Piwik.getTracker().getTrackerUrl()
“”
Piwik.getAsyncTracker().getTrackerUrl()
“”

Any ideas?

Hi there, thanks for the report. That’s certainly very interesting. would you mind posting this as a bug report in: Issues · matomo-org/piwik · GitHub ? it’s the first time we hear of a bug since we changed the include code to remove the protocol in Changed JavaScript Tracking Code generation to use “//” by Irrational86 · Pull Request #344 · matomo-org/piwik · GitHub

I am not so sure the use of ‘//’ is the problem, as the same result occurs when I add ‘https://’ to the tracking code.

The problem was probably due to when / where the tracking code snippet was run (inside a much larger web app framework). It worked for Google Analytics but not for Piwik, despite their similarities. I’ve resolved the problem by not loading the tracking code with the web app framework.