Store Custom Data in Database?

It is possible to store custom Data in the Database of Piwik? In the Plugin Documentation for Developers, i`ve seen “Execute SQL queries”. Any guidelines to store Data in the Database?

It is possible see Custom Variables Analytics - Analytics Platform - Matomo

No, i don`t mean the custom variables. Let me explain. I will create an Plugin (Dashboard Element) for my company, that received external Data from an API (XML-Feed). For this API i need an API-Key and a Account Number. The User of the Plugin needs the possibility to set the API-Key and the Account Number in the Plugin, before i can received the data from the API.

In the Feedburner Plugin, a “feedburnerName” will store in database. But is there any “database shema guidelines” i have to consider? What will happen with the Data after an Piwik Update?

It is comparably to WordPress. In WordPress has every Plugin his own Settings, that will stored under the plugin namespace in the database.

To store settings in the database, you can use the functions:


/**
 * Returns the option value for the requested option $name
 *
 * @param string $name Key
 * @return string|false Value or false, if not found
 */
function Piwik_GetOption($name)
{
	return Piwik_Option::getInstance()->get($name);
}

/**
 * Sets the option value in the database
 *
 * @param string $name
 * @param string $value
 * @param int $autoload if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request.
 */
function Piwik_SetOption($name, $value, $autoload = 0)
{
	Piwik_Option::getInstance()->set($name, $value, $autoload);
}

Don’t look at feedburner as it adds a field in the DB which is NOT the best practise (we will change it soon, to use the above functions, similar to wordpress option table)

Thank you very much. That is exactly what i am looking for. I guess, an option table like the wordpress option table is an good choice for piwik. Generally i like the WordPress Plugin System.