This Laravel 4 package allows you to insert the Piwik tracking code in your templates with the new Blade directive @piwiktracker.
It also has a feature that will allow you to hide your Piwik server URL by using the included proxy. This is great if you do not want anyone to find all of your sites by searching for the Pwik server URL.
Require the package in your composer.json and then run composer update
enabled: Allows you to enable or disable the insertion of the tracking code. Useful for when you are developing your site and dont need the visits tracked. Default is false.
site_id: Id of the site you are tracking. You can find this id in the Piwik settings under Tracking Code. Default is 0.
tracker_url: URL to the Piwik server. Should only be the hostname without the schema, for example mypiwik.com. You can add an additional path if your have installed the Piwik server in a sub-directory, for example mypiwik.com/piwik. Default is an empty string.
hidden: Set this to true if you want to hide the Piwik server url. We will then proxy all the requests to the tracker_url. This requires that you set a Piwik authorization token in the token option. Default is false.
token: A Piwik authorization token for a user that has access to the site that you want to track. Only used if hidden is set to true. Default is an empty string.
Adding the tracking code
In your layout (or any other template) add the new Blade directive @piwiktracker before the </body> tag and the tracking code should display if you have set enabled to true in the configuration file (and also set a valid site_id and tracker_url).
Hidden tracker URL
The Piwik Tracker Package has a feature of hiding the Piwik server URL (tracker_url in the config). You enable it by setting hidden to true and adding a valid token.
The actual tracking call will go to piwiktracker/php where we add the pageview via the Piwik API by using the token in the config. We also return the 1x1 gif file.
Laravel Piwik Tracker is licensed under the MIT License.