This is a complete rewrite of the script. Once you have Piwik running on your server, just fill in the information for your install and site id.
If you want to look at your stats from within your Vanilla install, just add your Piwik API key. (You can find it in the API tab in your Piwik install). Please note it's not needed to record stats, it provides you with you stats via iframe.
If you wish to include the whole Piwik in an iframe, remeber you need to edit your config/config.ini.php and add the following line:
If you also wish to enable the "Settings" pages (Manage websites, Users, etc.) to load in an iframe you can also add the setting: enable_framed_settings=1
As a best practice, I would create a new user/API with a view only access rather than using the Super Admin API key if there is shared access to the backend with other users.