How can I track with php? (i.e., without JavaScript)

Hi,

how can I track my visits with php and without using JavaScript?

Thanks in advance

visualex

Hi visualex,

Welcome to the Piwik community forums!

Currently, it is only possible to use JavaScript tracking tag code with Piwik. There is no possibility to use a local mode (PHP) tag.

this thread is a couple of weeks old and in the meantime several updates has been released. so, i am full of hope that it is now possible to track directly through the PHP-API - is it?

or is there any practicable work around to do some basic tracking through the PHP-API?

thank you very much in advance.

I too am wishing for this. That way I can also track crawlers / search bots like CrawlerTrack does.

ok i already posted this on a different thread but i figured it could help you as well.

What i ended up doing is not pretty but working.
In my download script i add the following code:

<?php $GLOBALS['PIWIK_TRACKER_DEBUG'] = false; define('PIWIK_TRACKER_MODE', true); define('PIWIK_INCLUDE_PATH', '/var/www/html/piwik'); @ignore_user_abort(true); set_include_path(PIWIK_INCLUDE_PATH . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/core' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/libs/' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/plugins/' . PATH_SEPARATOR . get_include_path() ); require_once "Common.php"; require_once "PluginsManager.php"; require_once "Tracker.php"; require_once "Tracker/Config.php"; require_once "Tracker/Action.php"; require_once "Cookie.php"; require_once "Tracker/Db.php"; require_once "Tracker/Visit.php"; require_once "Tracker/GoalManager.php"; $my_array= array('idsite' => '1','download' => $mydownloadurl , 'redirect' => '0' ); $_GET=$my_array; ob_start(); $process = new Piwik_Tracker; $process->main(); ob_clean(); ?>

I cooked this from different readings. but the bottom line is that it is working.
The only problem i am trying to solve now is that it refuses to load the “Goal” plugin.
Any suggestion to make this better or even to get the goal plugin to load would be most welcome.

Cheers,

D.

Hi,

I have several related sites, but would prefer people not be able to do competitive research on me and reverse-engineer my business model. So I’d like to use Piwik at a central server, but don’t want my use of Piwik to be a “footprint” that shows that the sites are related.

At first I thought there might be a way to use PHP instead of javascript for cookies/data. This would let me hide what I’m doing in the PHP code. But I found that PHP isn’t really supported.

Any ideas? It looks like an awesome system and I really like that we can code plugins. Thanks.

B

I did something similar, and wrote a blog post about it. Its just a small PHP proxy that will pass the request to the central server. On each site, you just need this small proxy file and the piwik.js file, and change the proxy to point to your central server.

This will probably not log the properties Piwik pulls from the browser DOM using JavaScript like screen resolution, app support (windows media, pdf, java, flash, shockwave, quicktime etc) and the clients time. There is also a plan to implement non JavaScript tracking using an image:

http://dev.piwik.org/trac/ticket/653

Well you can add to the array any information you need. but my basic need was to track downloads from my php script. Now i am back into the code looking why it refuses to pull the Goal plugin.

D.

[quote=kolchak @ Apr 20 2009, 05:11 AM]This will probably not log the properties Piwik pulls from the browser DOM using JavaScript like screen resolution, app support (windows media, pdf, java, flash, shockwave, quicktime etc) and the clients time. There is also a plan to implement non JavaScript tracking using an image:

http://dev.piwik.org/trac/ticket/653[/quote]

I’m trying to use Pwiki to make statistics for a wap site, but when I access with old devices, without javascript I can see the access on overview, but can’t see the goal, I believe that is happening is using because those devices doesn’t have support for javascript. Anyone know how to fix it?

My site shows a lot of video as well as allows others to embed our video content (standard flash player stuff). While I can clearly use Piwik to track all the details of my pages that are hit, my question is regarding tracking the actual FLV files that are hit. How would I do this?

What’s the problem? The .FLV files are loaded by the player, which is an object on the html page. The file is not even a parameter on the object, rather the player object is pointed to an .xml file on the server which includes the file name to access.

Further, as I said above, another site can pick up and embed a video, which results in them loading the player on their page and it operating the same way.

Is there any way Piwik can be used for this level of tracking?

You can try client-side tracking by having the player call the JavaScript tracking API. See example for JW Video Player. http://forum.piwik.org/index.php?showtopic=1304&st=0

Or wait for the server-side tracker API.

Since we’re operating in the player context, not the browser context - running Javascript is not an option. Now the player can hit an extended URL though.

[quote=vipsoft @ Aug 11 2009, 03:08 PM]You can try client-side tracking by having the player call the JavaScript tracking API. See example for JW Video Player. http://forum.piwik.org/index.php?showtopic=1304&st=0

Or wait for the server-side tracker API.[/quote]

Hello,

Is there any documentation on the exact structure of the actual HTTP request generated from the JS tracking code to record and collect data.

I am facing a situation in which I might not be able to use JS client side to track the data and might want to use server side HTTP to directly record the data.

What I basically need is an API to collect the data rather than just use the JS tracking code.

Thanks,
Arie

The underlying HTTP request generated by the JavaScript tracking isn’t part of the documented API. If you want to construct your own HTTP requests, you can study the uncompressed code in js/piwik.js.

A server-side tracking API is in development (i.e., I have running code) but I don’t have an ETA.

Hi

I have a directory full of files on my web space which I’d like to smarten up, so I’m writing a PHP script which is called via mod_rewrite when a user requests a file or folder. When given a directory it list files and subdirs in a table, including icons and a fancy header and footer. Adding the javascript tracking code to the HTML output is easy in this case.

When the user requests a file, I’d like to return the entire file without any redirects. I’d also like to track such downloads like a standard page view, preserving the IP address, HTTP headers and so on.

Is there a recommended way to remotely insert a new request into the piwik database? Also, because my stats are running on a different subdomain, user cookies won’t be valid. Is there a way around this problem or is this something I have to live with?

I’ve merged these posts as tracking via PHP is coming real soon now.

A first-cut of the server-side tracking API has been uploaded to Trac. (see http://dev.piwik.org/trac/ticket/134))

Excellent, just what I need. Thank you! style_emoticons/<#EMO_DIR#>/smile.gif

I’ll open source my mod_rewrite based file list thing with piwik built-in once I’ve finished it

[quote=vipsoft @ Aug 29 2009, 04:16 AM]I’ve merged these posts as tracking via PHP is coming real soon now.

A first-cut of the server-side tracking API has been uploaded to Trac. (see http ://dev.piwik.org/trac/ticket/134)[/quote]

I would be very interested on tracking via PHP, but the link above resulted in an error page. Is there a typo?

Thanks.
Mike

correct link is http://dev.piwik.org/trac/ticket/134