mcProgrammer mcProgrammer - 20 days ago 5
PHP Question

static graph or widget out of piwik for pageview evolution of single page(name)

What I need is the evolution of pageviews for a single Page Name, shown in a graph, available as widget or static image for embedding in another website.
In the Piwik website itself, this graph is available: go to Actions -> Page Titles, and hover over a certain page title -> two icons appear, one of which ('open row evolution') leads to the graph I want to export.

Through the API, I'm able to get statistics on my single page:

index.php?method=Actions.getPageTitle&pageName=PageNameIWant&date=last10&period=month&module=API&idSite=6&token_auth=anonymous

And I can also generate a graph:

index.php?module=API&method=ImageGraph.get&idSite=6&token_auth=anonymous&period=day&date=last100&apiModule=Actions&apiAction=getPageTitles

But I can't seem to find a way to combine the two to generate a graph showing the pageview evolution of a single page. Note that the first call uses the 'getPageTitle' method, while the second uses 'getPageTitles'. Using 'getPageTitle' in the second call generates an error (not supported)... I'd leave it at that if it weren't for the fact that the actual graph I'm looking for is available on the Piwik website itself, so there probably is some way to generate it.

Answer

The "label" option can be used for filtering for apparently any call that has multiple resulting rows.

index.php?module=API&method=ImageGraph.get&idSite=6&token_auth=anonymous&period=day&date=last100&apiModule=Actions&apiAction=getPageTitles &label=PageNameIWant

If you have many pages and you're getting a "No data for this graph" as result, possibly the page you're asking for is not one of the more popular. I'm not having this issue myself, but if someone in future does and reads this: there's a filter or filter_rows option which you can set to 0.