I have reconfigured plugin and I looked deeper into the code, then I found this: “<!– Site will be created and tracking code added on next request –>” in my page source. I have not seen this before because I was looking for Piwik code. I activated the logger by setting the WP_PIWIK_ACTIVATE_LOGGER in config.php to “2”.
I went to the requested URL address: piwik.example.com/?module=API&method=API.getBulkRequest&format=json&urls[0]=method%3DSitesManager.getSitesIdFromSiteUrl%26idSite%3Dn%2Fa%26url%3Dhttp%3A%2F%2Fexample.com%2Fdevelopment%2Fplayground&token_auth=… and I noticed that server response an empty value (), but when I delete the subdirectories from path by assigning the http%3A%2F%2Fexample.com to the &url I receive the correct idSite.
The following codes limit my ability to use your plugin successfully:
$id = WP_Piwik\Request::register ( 'SitesManager.getSitesIdFromSiteUrl', array (
'url' => $isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->siteurl
) );
[...]
if ($this->isNetworkMode () && self::$settings->getGlobalOption ( 'track_mode' ) == 'manually') {
$siteId = $this->getPiwikSiteId ();
if ($siteId != 'n/a')
echo str_replace ( '{ID}', $siteId, $trackingCode->getTrackingCode () );
else
echo '<!-- Site will be created and tracking code added on next request -->';
}
It uses get_bloginfo(‘url’) to create the request, however I have only global domain added to Piwik for all my WordPress Network pages (https://example.com instead
https://example.com/development/playground), so it can not get proper Piwik idSite. I would venture an attempt to make a patch extending plugin class, but I do not know if I will succeed. Perhaps I’m asking too much, but would you mind adding the ability to manually enter idSite or the address of the page that id should be used or maybe checkbox that enables plugin to use the main domain (without subdirectories) for WordPress Network ? I will be very grateful and I think this feature would be usefull not only for me.