Custom Variable Values by Visit Graph

Hello
I am trying to generate a graph, which visualizes the number of visits per value of a custom variable by day. This proves to be a lot harder than I expected.
My current request looks like this:


http://stat.server.somewhere/?module=API&method=ImageGraph.get&idSite=3&apiModule=CustomVariables&apiAction=getCustomVariablesValuesFromNameId&language=en&token_auth=[token]&period=month&date=today&idsubtable=[randomNumber]

However this doesn’t quite work, thanks to subtables being weird. I can visualize the visits without the variables being into their values by using something like


http://stat.server.somewhere/?module=API&method=ImageGraph.get&idSite=3&apiModule=VisitsSummary&apiAction=get&token_auth=[token]&period=month&date=[datePeriod]&segment=customVariableName1=[variableName]

So I basically want this, but with a line per unique value.

Is there any way to actually get the results I am looking for?
Thanks in advance for your help!

could you please give example URLs of the demo.piwik.org ? if I see the graphs I could better help, cheers

The first graph I cannot draw. It is impossible, as the subtable Ids seem to change daily and don’t even always work - that’s my experience.
You can see the second graph here: http://demo.piwik.org/?module=API&method=ImageGraph.get&idSite=7&apiModule=VisitsSummary&apiAction=get&token_auth=anonymous&period=day&date=2013-11-11,2013-11-18
However I removed the

&segment=customVariableName3==Forum%20status

, as it a) doesn’t seem to work, because there is a space in the name or similar and b) is pointless, since every visitor has the variable defined.

What I am looking for is splitting up that graph into one line with the number of visitor having the customVar values anonymous and one for LoggedIn user. However I do not want to hardcode these values, as I don’t want to update the website every time we release a new version of our software.

Edit: one line of the graph should basically be this: http://demo.piwik.org/?module=API&method=ImageGraph.get&idSite=7&apiModule=VisitsSummary&apiAction=get&token_auth=anonymous&period=day&date=2013-11-11,2013-11-18&segment=customVariableValue3==Anonymous
However this has the value hardcoded.

i think the &flat=1 parameter will solve your problem; check this out: http://demo.piwik.org/?module=API&method=ImageGraph.get&idSite=7&apiModule=CustomVariables&apiAction=getCustomVariables&token_auth=anonymous&period=day&date=2013-11-11,2013-11-18&flat=1

Thank you, the only thing missing now is to only get the values of one variable, as we have multiple custom variables. I’ve tried to filter them with &segment=customVariableName1==Name, however the graph shows the values of both variables. If I set the segment condition to an inexistent value, the query is blank tough.

Try the parameter filter_pattern_recursive to keep only rows matching the specified string

http://demo.piwik.org/?module=API&method=ImageGraph.get&idSite=7&apiModule=CustomVariables&apiAction=getCustomVariables&token_auth=anonymous&period=day&date=2013-11-11,2013-11-18&flat=1&filter_pattern_recursive=.logged.

It is a regular expression so with:


&filter_pattern_recursive=.*logged.*

it’s matching only the rows containing “logged”

Thanks, that works perfectly.
For the record: I use

...&filter_pattern_recursive=[VarName]*

I didn’t even know it was really possible. Great to learn :wink: