45

In piwik, is it possible to filter the visitors graph based on a custom variable from the tracker? I want to show an evolution graph of all the visits with a 70 value in the first custom variable slot. I tried this call

index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=VisitsSummary&apiAction=get&token_auth=anonymous&graphType=evolution&period=day&date=2012-01-01,2012-07-10&width=500&height=250&filter_column=custom_var_v1&filter_pattern=70

but got

No data for this graph.

When I remove the filter_pattern I get a graph. I checked the piwik_log_visit table in the database and I have that value for visit records.

2

2 Answers 2

0

Create a segment with custom_var_v1 = 70 (I suggest setting it as pre-archived in case you have a lot of traffic).

0

When you use filtering:

You are using filter_column and filter_pattern which are global Piwik API filters. But you must be sure the custom variable data is present in the report you're querying. The VisitsSummary.get method might not contain the custom variable data by default.

When querying data based on custom variables, use the CustomVariables.getCustomVariables API method rather than VisitsSummary.get.

Your query would look like:

index.php?module=API&method=CustomVariables.getCustomVariables&idSite=1&period=day&date=2012-01-01,2012-07-10&token_auth=anonymous&filter_column=custom_var_v1&filter_pattern=70


Try Segmentation:

Instead of filtering, try segmentation. The segment parameter allows you to segment the data by various metrics, including custom variables. Try adding this segment parameter to your query:

&segment=custom_var_v1==70

Your query would look like:

index.php?module=API&method=CustomVariables.getCustomVariables&idSite=1&period=day&date=2012-01-01,2012-07-10&token_auth=anonymous&segment=custom_var_v1==70

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.