Log custom variable from a plugin?

I’m new to Piwik but not to PHP. My goal is to develop a plugin, or extension to the GeoIP plugin, that will log the user’s city and region as a custom variable. (This is the only way I can think of to associate the city and region with each specific user in the visit log.)

My question is, is there a way to create a custom variable with PHP in a Piwik plugin, or does it have to be done from Javascript? If from Javascript, that might be a problem, as the data to find the city and region is on the server-side.

Any thoughts on this would be appreciated. Thank you.

We plan to add/integrate the Geoip plugin to the core distribution with an option to also record state/region and city.

Cool! Is there a target version for that?