[solved] Hide Piwik server in js


(bamtel) #1

Is there a way to hide or obfuscate the Piwik server in the javascript and make it appear as piwik is running on the same server as the website being tracked?

I’ve tried some of the free online obfuscate sites but couldn’t get the code to work.

UPDATE: See solution in: How to - Analytics Platform - Matomo


(vipsoft) #2

You can use the PiwikTracker class for server-side tracking.


(bamtel) #3

Does that provide the same tracking as the javascript?

I have 100+ sites to install this on and don’t like the footprint that the javascript has.


(vipsoft) #4

Using the server-side tracker you would lose browser plugin detection, screen resolution, and some fixups (e.g., when a page is loaded via Google Translate or Cached page).

With respect to footprint. piwik.js is about 5K when gzip’d. If your Apache web server isn’t configured to compress static assets (e.g., mod_deflate), you can use Piwik’s proxy in the js/ folder (which will compress and cache the compressed file, and serve out headers for cacheability).


(bamtel) #5

I’m talking in terms of having the piwik server name visible in the source of the page.


(vipsoft) #6

It’s server-side tracking. No piwik.js to load and no URL to your piwik server.


(bamtel) #7

Okay Thanks.

I will have to see if I can figure out how to implement this.


#8

You could install Piwik on a subdomain and then use CNAME records to let it appear as subdomain on all other sites, like

piwik.site1.com
piwik.site2.com
piwik.site3.com
piwik.site4.com

This way, Piwik always looks like being hosted on the same site, but you still have 1 central tracking site.


(bamtel) #9

I may have to look into this as it looks like the phptracker class option doesn’t track what I need.

Info from documentation:
Note: the code doesn’t use Javascript so Piwik will not be able to track some user information such as search keywords, referer websites, screen resolutions, plugin support and page titles.


(bamtel) #10

I couldn’t get the subdomain to work kept getting a 403 error on the piwik server.

Is there any way to pass the referrer and keywords to phptracker api.


#11

You could also proxy your piwik installation under a specific context.

ProxyPass /piwik http://your.piwik.server
ProxyPassReverse /piwik http://your.piwik.server


(Matthieu Aubry) #12

Now a beta script is available, see instructions in the last comment in : Document how to hide piwik server URL in the Javascript · Issue #2019 · matomo-org/matomo · GitHub


#13

Hi Matt,

I been trying the script, but it does not seem to work. Followed the directions on the link.


(vipsoft) #14

In php.ini, you need:


allow_url_fopen = On


#15

Hi,

I have that setup in my php.ini on both the server and the clients, but still nothing.


(Matthieu Aubry) #16

SupraTT, what you can do, is the following:
0) edit piwik.php on your website (the “fake” one), and comment out the line // header(…)

  1. with Firebug, look at the NET panel
  2. open in a new tab, the request done to piwik.php?..
  3. look what is displayed, there might be an error?

#17

Hi Matt,

I am getting a 403 Forbidden.


(Matthieu Aubry) #18

there will be something in your error logs?


#19

Hi Matt,

Thank you for the suggestions. I checked my error logs, but there was nothing in them. I contacted my web host and told them I was getting a 403 for the piwik request and they whitelisted some rules that got everything working now.


#20

The tracking is working now, but outlinks/downloads are still not working… I don’t have any other javascript code on the website. I added class=‘piwik_link’ to each link I wanted to track.

I read the FAQ: Troubleshooting - Analytics Platform - Matomo

and it says increase the TrackingTimer:

piwikTracker.setLinkTrackingTimer( 750 ); // increase to 750 milliseconds

which I tried, but still nothing. I did look at the FireBug NET log and I notice that when I click on a link to be tracked the request just keeps waiting (looping?).