Need help with building a Page Counter

Hi All,
I’m try to add page counters to specific pages on My site.
e.g. how many vistits someone has had to their Profile page.
Seems like we should be able to do this with the API however, we can’t get it to run. Either we get all site traffic or a Ø.

Current code:
This code should put the number on the page.
nb_hits results in a Ø
nb_visits gives all visitors to the site.

How do we rewrite this to show visitors to a specific page?
Thank You!
Eric

<?php define('PIWIK_INCLUDE_PATH', './piwik'); //piwik directory define('PIWIK_ENABLE_DISPATCH', false); define('PIWIK_ENABLE_ERROR_HANDLER', false); require_once PIWIK_INCLUDE_PATH . "/index.php"; require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php"; Piwik_FrontController::getInstance()->init(); $token = 'XXXXXXXXXXXXXXXXXXXXXXXXX'; // using token from PIWIK admin $start = '2010-01-01'; // use the earliest date in your database $today = date('Y-m-d'); $request = new Piwik_API_Request(' method=VisitsSummary.get &idSite=1 &date='.$start.'%2c'.$today.' &period=day &format=PHP &serialize=0 &token_auth='.$token.' '); $result = $request->process(); $PageCountTotal = 0; foreach ($result as $index => $val) { @$PageCountTotal = $PageCountTotal + $val['nb_hits']; } echo "$PageCountTotal"; ?>

You probably should use the following API: Actions.getPageUrl

http://piwik.org/docs/analytics-api/reference/#Actions

Hi Matt,
Thank you for the speedy reply. However, I’m not sure what to do with that information.
I’m hacking this together based on another example I found in the forum. I’m happy with swapping things out, however, I’m not a good enough programmer to know what to do with “Actions.getPageUrl”. Or how that’s going to tell Piwik, get the count for the page that’s displaying.

Can you show me where that would fit into the code I posted?

When we’re done with this I intend to post the final working code here for anyone else who needs it.
Thank you,
Eric

This API Actions.getPageUrl returns the stats for a given page URL, so replace VisitsSummary.get by this call, and add the parameter “pageUrl” with the page URL you want data for, and it will return the stats for this page URL

Thank you Matt. I’ll give that a go.