Direct query to the db (sum of conversions)

Hi all!

First: I have Piwik on my site and I’m very happy with it! :slight_smile:

I have set up a “goal”. Now: i would like to query the piwik database via PHP to get the total number of conversions (just the total, i dont mind the date rage, etc.). I need to use that numer on another application (witch sum the total conversions from different sources).

Could you please help me out? Thanks!

matt: I think jack wants “subdomain” to be a segment.

(editorial note: this comment was intended for another topic)

It’s easier! I do not have subdomains. The other sources are external websites witch i do not host.

The only thing i need to do is to get from the db the total number of times the goal “XYZ” has been reached (unique users). The goal is the “id=2” in “piwik_goal” table. :slight_smile:

I guess i have to query the “piwik_log_conversion” table in some way…


click on the API link on your dashboard;
scroll down the list of API methods to Goals.getConversions()

(sorry, I know you asked for direct db access.)

well… i need that number in a php variable, how i get it it doesent matter so much. can i use the api in some way?

thanks :wink:

any clue? :slight_smile:


Jack, yes you can use it see example in piwik/misc/exampleAPI *.php

Thanks matt! I tried to look at “api_rest_call.php” and “api_internal_call.php” but i really do not understand where to start ;). Is there an online references or some pratical example somewhere?

Thanks in advance,

See the file api_community_sticker.php