How to get $UserId, CustomVariables,... inside PlugIn?


#1

Hello!

I’m trying to get the UserID and CustomVariables (1,2,… from scope visit) inside my Plugin, after the “Tracker.recordAction” hook… and pass it through to SQL Query.

But i have no clue how to get the Variables, can you please point me into the right direction?


class MyPlugin extends Plugin{

    public function getListHooksRegistered(){
        return array(
		
		'Tracker.recordAction' => array(
                'after' => true,
                'function' => 'getVisitorDetails'
			
            )
        );
    }

    public function getVisitorDetails(){
		
		// HOW TO CALL / GET THE VARIABLES FROM PIWIK VISIT?
		$userid = '?';
		$uservariable1 = '?';
		$uservariable2 = '?';
		
		// ...
		
		// Make a MySQL Connection
		mysql_connect("localhost", "externaldb", "dbpass") or die(mysql_error());
		mysql_select_db("externaldb") or die(mysql_error());
		
		$query    = "INSERT INTO user_table (row1, row2, row3) 
					 VALUES('$userid', '$uservariable1', '$uservariable2')";
		mysql_query($query) or trigger_error(mysql_error()." in ".$query);
		
	}
}