Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piwik Localhost Tracking

Tags:

matomo

On piwik, I use localhost as a test website. When I type in localhost from my computer, piwik updates its statistics correctly but when another person (co-worker) in the same LAN types in my IP address, it shows the webpage but piwik doesn't update the visits/pageview count. I would like to know why is that? Any help would be appreciated.

like image 301
jonathan1987 Avatar asked Dec 03 '12 17:12

jonathan1987


People also ask

How does Piwik PRO collect data about visitors?

Piwik PRO uses a tracking code (a JavaScript code) to collect data about people who visit your site or app. The tracking code is part of the container embedded on your web pages. Every time a visitor views a page, the tracking code grabs information about that visitor and sends it to Piwik PRO. Then Piwik PRO organizes this data into reports.

Why is Matomo (Piwik) not tracking my visits?

There are several possible reasons why Matomo (Piwik) is not tracking your visits properly: Incorrect Matomo tracking code Please check that you can find the Matomo javascript code on your website pages that you wish to track.

How to track Cookieless by default in Piwik PRO?

Inside the Piwik PRO settings tab Whenever cookieless tracking requires asking for consent, Piwik PRO’s built-in consent manager helps easily get proper consent. Google Analyticsdoes not offer any possibility to track cookieless by default.

Why can’t I access Piwik?

Access to piwik.php fails If your host uses mod_security to block requests containing URLs (eg. hosts like HostGator, The Planet), check out the Matomo and mod_security FAQ.


2 Answers

You need to add your IP to the trusted_hosts[] configuration. If you installed Piwik under localhost, it will only accept tracking requests if called under that name.

In config.ini.php add:

[General]
trusted_hosts[] = localhost
trusted_hosts[] = 192.168.1.12

Where 192.168.1.12 is your IP address within your LAN:

like image 186
halfdan Avatar answered Sep 19 '22 23:09

halfdan


This config [General] trusted_hosts[] = localhost

says on which address you can access Piwik, its admin panel. If you want to track LAN page you have to modify its Tracking code. To get right for you tracking code (it will not work if you have dynamic IP in your network):

  • add to trusted_hosts IP address you have in LAN
  • enter Piwik Admin Panel not by localhost but by your LAN address eg. 192.168.1.12
  • Now all tracking codes will have your IP as server address and will fire requests to your computer where Piwik is installed.

Explaination:

This all happens because when you enter Piwik Admin Panel from your localhost all tracking codes will have localhost as you Piwik address. So if somebody enters webpage with tracking code, browser will try to communicate with user localhost which is: His Computer. and probably he doesn't have your Piwik.

like image 44
Sebastian Piskorski Avatar answered Sep 20 '22 23:09

Sebastian Piskorski